VB6变量声明中的星号表示什么含义?

2026-05-06 11:321阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计557个文字,预计阅读时间需要3分钟。

VB6变量声明中的星号表示什么含义?

在变量声明后,星号(*)和数字的含义是什么?例如,在WpName + As + String + * + 6中看到的这样:Public Type WayPoint WpIndex + As + Integer WpName + As + String + * + 6 WpLat + As + Double WpLon + As + Double WpLatDir + As + String + * + 1 WpLonDir + As + String

星号(*)在这里通常表示一个指针。在编程中,指针是一个变量,它存储了另一个变量的内存地址。在这种情况下,星号(*)后的数字6可能表示该字符串变量的大小或长度,或者是它指向的内存区域的大小。

例如,这里的代码片段似乎定义了一个结构体(或类)`WayPoint`,它包含以下字段:

- `WpIndex`:一个整型变量,用于存储点索引。- `WpName`:一个字符串变量,长度为6个字符。- `WpLat`:一个双精度浮点型变量,用于存储纬度。- `WpLon`:一个双精度浮点型变量,用于存储经度。- `WpLatDir`:一个字符串变量,长度为1个字符。- `WpLonDir`:一个字符串变量,长度未知。

这里的`*`和数字`6`结合使用,意味着`WpName`是一个长度为6的字符串,而不是一个指向字符串的指针。在其他情况下,如果没有数字,`*`可能表示一个指针,例如`WpName *`意味着`WpName`是一个指向字符串的指针。

在变量声明之后,星号(*)和数字的含义是什么?如在WpName As String * 6中看到的那样

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 星号将变量声明为固定长度的字符串,其中数字表示字符串的长度:

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

The declaration of a fixed-length string variable contains an asterisk (*) to tell Visual Basic that the string will be a fixed length. The final parameter, strlength, tells the program the number of characters that the variable can contain.

它们可能是API调用所必需的,请参阅此问题:

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

The only time in VB6 or earlier that I had to use fixed length strings was with working with API calls.

VB6变量声明中的星号表示什么含义?

本文共计557个文字,预计阅读时间需要3分钟。

VB6变量声明中的星号表示什么含义?

在变量声明后,星号(*)和数字的含义是什么?例如,在WpName + As + String + * + 6中看到的这样:Public Type WayPoint WpIndex + As + Integer WpName + As + String + * + 6 WpLat + As + Double WpLon + As + Double WpLatDir + As + String + * + 1 WpLonDir + As + String

星号(*)在这里通常表示一个指针。在编程中,指针是一个变量,它存储了另一个变量的内存地址。在这种情况下,星号(*)后的数字6可能表示该字符串变量的大小或长度,或者是它指向的内存区域的大小。

例如,这里的代码片段似乎定义了一个结构体(或类)`WayPoint`,它包含以下字段:

- `WpIndex`:一个整型变量,用于存储点索引。- `WpName`:一个字符串变量,长度为6个字符。- `WpLat`:一个双精度浮点型变量,用于存储纬度。- `WpLon`:一个双精度浮点型变量,用于存储经度。- `WpLatDir`:一个字符串变量,长度为1个字符。- `WpLonDir`:一个字符串变量,长度未知。

这里的`*`和数字`6`结合使用,意味着`WpName`是一个长度为6的字符串,而不是一个指向字符串的指针。在其他情况下,如果没有数字,`*`可能表示一个指针,例如`WpName *`意味着`WpName`是一个指向字符串的指针。

在变量声明之后,星号(*)和数字的含义是什么?如在WpName As String * 6中看到的那样

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 星号将变量声明为固定长度的字符串,其中数字表示字符串的长度:

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

The declaration of a fixed-length string variable contains an asterisk (*) to tell Visual Basic that the string will be a fixed length. The final parameter, strlength, tells the program the number of characters that the variable can contain.

它们可能是API调用所必需的,请参阅此问题:

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

The only time in VB6 or earlier that I had to use fixed length strings was with working with API calls.

VB6变量声明中的星号表示什么含义?