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

后端 未结 3 974
余生分开走
余生分开走 2021-01-25 07:11

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

相关标签:
3条回答
  • 2021-01-25 07:56
    Dim myString as String * 1000
    
    0 讨论(0)
  • 2021-01-25 08:00

    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
    
    0 讨论(0)
  • 2021-01-25 08:10

    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 讨论(0)
提交回复
热议问题