【问题标题】:Asterisks in variable declarations in VB6VB6 变量声明中的星号
【发布时间】:2011-09-03 13:37:08
【问题描述】:

变量声明后的星号(*)和数字是什么意思?如WpName As String <strong>* 6</strong>中所见@

Public Type WayPoint

   WpIndex As Integer
   WpName As String * 6
   WpLat As Double
   WpLon As Double
   WpLatDir As String * 1
   WpLonDir As String * 1

End Type

【问题讨论】:

    标签: vb6 variable-declaration


    【解决方案1】:

    星号将变量声明为定长字符串,其中数字表示字符串的长度:

    http://www.1sayfa.com/1024/diger/vb/ch07.htm#Heading8

    固定长度字符串变量的声明包含一个星号 (*),以告知 Visual Basic 该字符串将是固定长度。最后一个参数 strlength 告诉程序变量可以包含的字符数。

    API 调用可能需要它们,请参阅此问题:

    VB6 - Is there any performance benefit gained by using fixed-width strings in VB6?

    在 VB6 或更早版本中,我必须使用固定长度字符串的唯一一次是使用 API 调用。

    【讨论】:

    • 如果您正在执行随机访问文件 I/O,您通常也会在定义记录布局时使用星号 (*)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-18
    • 2015-02-06
    • 2011-05-18
    相关资源
    最近更新 更多