Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a VB6 module to VB.NET

I'm almost done converting a module from VB6 to VB.NET, but I'm having trouble with the following 2 quotes and am wondering if there's any way to go about this:

Structure AUDINPUTARRAY
    bytes(5000) As Byte
End Structure

I'm trying to change that bytes line to: Dim bytes(5000) as Byte but it's not letting me define the size in a structure.


Here's the second one:

Private i As Integer, j As Integer, msg As String * 200, hWaveIn As integer

I haven't a clue on how to convert: msg As String * 200

like image 732
user1060582 Avatar asked Dec 02 '11 04:12

user1060582


People also ask

Is VB.NET compatible with VB6?

Visual Basic.NET supports upgrading from VB6; however, if your application is written in any version prior to 6, you will have to upgrade it to VB6 prior to upgrading it to VB.NET. Visual Basic.NET can be installed on a computer that has Visual Basic 6 installed, and both can run at the same time.

How do I import a VB6 project into visual studio?

Make sure you are clicking on the project file itself... Right click on the file and select "Open With" and select your visual studio program. It may need to be converted and if so, it will prompt you to convert the project.

Is VB.NET faster than VB6?

VB6 methods tend to be slower than their VB.NET counterparts.

Is VB6 obsolete?

VB6 was eventually discontinued. Microsoft released Visual Basic . NET as part of Microsoft's . NET runtime library.


1 Answers

you cannot declare an initial size in VB.Net , you can set its size later using Redim statement in constructor or wherever needed

Structure AUDINPUTARRAY
    Public bytes() As Byte
    Public Sub New(ByVal size As Integer)
        ReDim bytes(size) ' set size=5000

    End Sub


End Structure

In Visual Basic .NET, you cannot declare a string to have a fixed length unless you use the VBFixedStringAttribute Class attribute in the declaration. The code in the preceding example causes an error.

You declare a string without a length. When your code assigns a value to the string, the length of the value determines the length of the string see http://msdn.microsoft.com/en-us/library/f47b0zy4%28v=vs.71%29.aspx . so your declarration will become

    Private i As Integer, j As Integer, hWaveIn As Integer
    <VBFixedString(200)> Private msg As String
like image 111
Akshita Avatar answered Sep 30 '22 10:09

Akshita