2011-09-03 54 views
3

变量声明后星号(*)和数字的含义是什么?如在WpName As String * 6VB6变量声明中的星号

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 

回答

6

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

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工作调用。

+0

如果您正在进行随机存取文件I/O,那么在定义记录布局时通常也会使用星号(*)。 – tcarvin