Convert Type to a Structure 
Author Message
 Convert Type to a Structure

How do I change this vb5 code to .net code.

VB5
Public Type RecordType
    NoteName As String * 50
    NoteCode As String * 1000
End Type
Public MyNotes As RecordType

I've tried the following but I get an error. I need the strings to be
a length that allows reading a record from a file.

Structure RecordType
    Public NoteName as String=New String(" "c,50)
    Public NoteCode as String=New String(" "c,1000)
End Structure

Public MyNotes As RecordType



Wed, 19 Jan 2005 10:49:10 GMT  
 Convert Type to a Structure
If you must, you can use the VB6 compatibility layer. Strings in NET are not
fixed length


Quote:
> How do I change this vb5 code to .net code.

> VB5
> Public Type RecordType
>     NoteName As String * 50
>     NoteCode As String * 1000
> End Type
> Public MyNotes As RecordType

> I've tried the following but I get an error. I need the strings to be
> a length that allows reading a record from a file.

> Structure RecordType
>     Public NoteName as String=New String(" "c,50)
>     Public NoteCode as String=New String(" "c,1000)
> End Structure

> Public MyNotes As RecordType



Wed, 19 Jan 2005 10:55:45 GMT  
 Convert Type to a Structure
Try
Structure RecordType
    dim NoteName as new
Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString(50)
   ...
end structure


Quote:
> How do I change this vb5 code to .net code.

> VB5
> Public Type RecordType
>     NoteName As String * 50
>     NoteCode As String * 1000
> End Type
> Public MyNotes As RecordType

> I've tried the following but I get an error. I need the strings to be
> a length that allows reading a record from a file.

> Structure RecordType
>     Public NoteName as String=New String(" "c,50)
>     Public NoteCode as String=New String(" "c,1000)
> End Structure

> Public MyNotes As RecordType



Wed, 19 Jan 2005 11:09:44 GMT  
 Convert Type to a Structure
   Structure RecordType
      Public NoteName As String
      Public NoteCode As String
      Sub New(ByVal dummy As Int32)
         Me.NoteName = New String(" "c, 50)
         Me.NoteCode = New String(" "c, 1000)
      End Sub
   End Structure

Use:
Dom uMyStruct as new RecordType(0)

HTH
Corrado



Wed, 19 Jan 2005 15:32:57 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Converting C structure to VB5 type

2. VB6: How to initialize a variable as a array structure / structure (type) array (see example)

3. object type cannot be converted to target type

4. Convert array of value type to array of reference type

5. object type cannot be converted to target type

6. how to convert INT type to UINT16 type?

7. Inheritance and Converting base types to child types

8. Q: Converting VB types to equivalent C types

9. Converting a String Type to an Object Type

10. problem of converting C's union type to VB's a data type

11. problem of converting C's union type to VB's a data type

12. Q: Converting VB types to equivalent C types

 

 
Powered by phpBB® Forum Software