Thursday, April 21, 2011

How to declare variable containing character limiting to 1000 bytes in vb6

How to declare variable containing character limiting to 1000 bytes in vb6

From stackoverflow
  • This is a rough approximation. It assumes you are flexible with that 1000 byte limit.

    Private mData As String
    Public Property Let Data(value As String)
    
        If Len(value) <= 1000 Then
            mData = value
        Else
            'Do whatever '
        End If
    
    End Property
    
  • Dim myString as String * 1000
    
    ChaosPandion : I had no idea... +1
  • Here is the syntax for a fixed-length string of 500 characters, which is 1000 bytes. VB6 strings are Unicode (UTF-16) and therefore each character has two bytes. The value of a fixed-length string will always have 500 characters - trailing spaces will be added, or excess characters truncated.

    Dim s As String * 500  ' 500 characters, 1000 bytes
    

    I wonder whether you are dealing with binary data rather than text. The Byte data type is better for binary data.

    Dim byt(1000) as Byte  ' an array of 1000 bytes
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.