How do i Declare a string like this:
Dim strBuff As String * 256
in VB.NET
thanks
How do i Declare a string like this:
Dim strBuff As String * 256
in VB.NET
thanks
Have you tried
Dim strBuff as String
Also see Working with Strings in .NET using VB.NET
This tutorial explains how to represent strings in .NET using VB.NET and how to work with them with the help of .NET class library classes.
Use the VBFixedString attribute. See the MSDN info here
<VBFixedString(256)>Dim strBuff As String
To write this VB 6 code:
Dim strBuff As String * 256
In VB.Net you can use something like:
Dim strBuff(256) As Char
It depends on what you intend to use the string for. If you are using it for file input and output, you might want to use a byte array to avoid encoding problems. In vb.net, A 256-character string may be more than 256 bytes.
Dim strBuff(256) as byte
You can use encoding to transfer from bytes to a string
Dim s As String
Dim b(256) As Byte
Dim enc As New System.Text.UTF8Encoding
...
s = enc.GetString(b)
You can assign 256 single-byte characters to a string if you need to use it to receive data, but the parameter passing may be different in vb.net than vb6.
s = New String(" ", 256)
Also, you can use vbFixedString. I'm not sure exactly what this does, however, because when you assign a string of different length to a variable declared this way, it becomes the new length.
<VBFixedString(6)> Public s As String
s = "1234567890" ' len(s) is now 10