Solved

VB to VB.Net upgrade errors. help

Posted on 2004-03-31
13
1,009 Views
Last Modified: 2007-12-19
Can anyone please help me with the solution for the question at the following URL

http://dbforums.com/arch/26/2002/7/444205

Added to that I have some "Return"  keywords in my VB program which Vb.Net upgrade wizard gives an error. How to resolve that error.

I am facing with the same kind of problems metioned there

Thanks in advance
0
Comment
Question by:ramesh12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
13 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 10725573
Every function myst have a return statement
0
 
LVL 7

Author Comment

by:ramesh12
ID: 10725715
When I have upgraded my vb6 program VB.Net shows something like this

            lbldisplay(LabelNum_int_g).Text = Dsp_stg
            lbldisplay(LabelNum_int_g).Visible = True
            LabelNum_int_g = LabelNum_int_g + 1
            'UPGRADE_WARNING: Return has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
            Return



and my original vb code is something like this

  lbldisplay(LabelNum_int_g).Caption = Dsp_stg
  lbldisplay(LabelNum_int_g).Visible = True
  LabelNum_int_g = LabelNum_int_g + 1

  Return


Problem is not with the returning of values from a function. For now I just commented out return to see what happens . BUt my main problem is with converting "AS ANY" to proper type. How do I change that.

Thank you
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10725733
do as Object instead
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 48

Expert Comment

by:Mikal613
ID: 10725739
post your Full Function you have the problem with
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10725743
as any and variant are no longer supported and replaced as Object
0
 
LVL 48

Accepted Solution

by:
Mikal613 earned 500 total points
ID: 10725753
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10725758
There are three cases where you may need to make some changes. The first is passing user-defined types that contain fixed-length strings or byte arrays to APIs. In Visual Basic .NET you may need to change your code, adding the MarshallAs attribute (from System.Runtime.InteropServices) to each fixed-length string or byte array in the user-defined type. The second case is using the As Any variable type in a Declare statement. This is not supported in Visual Basic .NET. Variables of type As Any were often used to pass a variable that was either a string or Null; you can replace this Visual Basic 6.0 usage by declaring two forms of the API, one with longs, one with strings. For example, the GetPrivateProfileString API has a parameter lpKeyName of type As Any:

0
 
LVL 7

Author Comment

by:ramesh12
ID: 10725843
I have something like this in VB

Declare Sub hMemCpy Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Source As Any, ByVal Copy As Long)


and that is converted like this

      'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1016"'
      'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1016"'
    Declare Sub hMemCpy Lib "kernel32" Alias "RtlMoveMemory" (ByRef Dest As Any, ByRef Source As Any, ByVal Copy As Integer)



In VB I am using calls like this

  Dim MinorWindowsVersion_Byte    As Byte
  Dim MajorWindowsVersion_Byte    As Byte

  Dim WordStuct     As DoubleWord
  Dim ByteStruct    As DoubleByte


'retrieve version via API call & copy into double-word structure
 
  Call hMemCpy(WordStuct, GetVersion(), Len(WordStuct))

'copy low word into double byte structure
  Call hMemCpy(ByteStruct, WordStuct.LowWord, Len(ByteStruct))


and this is converted to

            Dim MinorWindowsVersion_Byte As Byte
            Dim MajorWindowsVersion_Byte As Byte
            
            Dim WordStuct As DoubleWord
            Dim ByteStruct As DoubleByte
            
            
            'retrieve version via API call & copy into double-word structure
            
            'UPGRADE_WARNING: Couldn't resolve default property of object WordStuct. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
            Call hMemCpy(WordStuct, GetVersion(), Len(WordStuct))
            
            'copy low word into double byte structure
            'UPGRADE_WARNING: Couldn't resolve default property of object ByteStruct. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
        Call hMemCpy(ByteStruct, WordStuct.LowWord, Len(ByteStruct))
            

What should I do with ANY now. Actually the documentation says it takes pointers to the source and destination .Here is the URL

http://msdn.microsoft.com/library/en-us/memory/base/copymemory.asp?frame=true
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10725891
Declare Sub hMemCpy Lib "kernel32" Alias "RtlMoveMemory" (Dest As String, Source As Any, ByVal Copy As Long)


0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10725897
it says to change the As Any to String or long Dest seems to be a string
0
 
LVL 7

Author Comment

by:ramesh12
ID: 10726002
Thanks Mikal
                   I removed entirely hMemCpy from my program and made some changes, and my program is returning the results that I want.

But basically that particular hMemCopy is being used to check for the OS version. Here is the code

Declare Function GetVersion Lib "kernel32" () As Long

Private Function ValidWindowsVersion_bool() As Boolean

  Dim MinorWindowsVersion_Byte    As Byte
  Dim MajorWindowsVersion_Byte    As Byte

  Dim WordStuct     As DoubleWord
  Dim ByteStruct    As DoubleByte


'retrieve version via API call & copy into double-word structure
 
  Call hMemCpy(WordStuct, GetVersion(), Len(WordStuct))

'copy low word into double byte structure
  Call hMemCpy(ByteStruct, WordStuct.LowWord, Len(ByteStruct))

'set version
  MinorWindowsVersion_Byte = ByteStruct.LowByte
  MajorWindowsVersion_Byte = ByteStruct.HighByte


'set whether this is a valid version
  If MajorWindowsVersion_Byte >= 4 Then
'it's at least Windows 4.0 (Windows 95)
    ValidWindowsVersion_bool = True
  Else
    ValidWindowsVersion_bool = False
  End If

End Function

So I have removed this . Now Is there any easy way in .net to check this

0
 
LVL 7

Author Comment

by:ramesh12
ID: 10726035
I think I have got everything set. I really appreciate your help Mikal.

Thank you
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10726051
Public Function OS_Version() As String

        Dim osInfo As OperatingSystem
        Dim sAns As String

        osInfo = System.Environment.OSVersion

        With osInfo
            Select Case .Platform
                Case .Platform.Win32Windows
                    Select Case (.Version.Minor)
                        Case 0
                            sAns = "Windows 95"
                        Case 10
                            If .Version.Revision.ToString() = "2222A" Then
                                sAns = "Windows 98 Second Edition"
                            Else
                                sAns = "Windows 98"
                            End If
                        Case 90
                            sAns = "Windows Me"
                    End Select
                Case .Platform.Win32NT
                    Select Case (.Version.Major)
                        Case 3
                            sAns = "Windows NT 3.51"
                        Case 4
                            sAns = "Windows NT 4.0"
                        Case 5
                            If .Version.Minor = 0 Then
                                sAns = "Windows 2000"
                            ElseIf .Version.Minor = 1 Then
                                sAns = "Windows XP"
                            ElseIf .Version.Minor = 2 Then
                                sAns = "Windows Server 2003"
                            Else 'Future version maybe update
                                 'as needed
                                sAns = "Unknown Windows Version"
                            End If
                    End Select

            End Select
        End With

        Return sAns
    End Function
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question