Asterisks in variable declarations in VB6

耗尽温柔 提交于 2019-12-01 17:14:01

问题


What's the meaning of the asterisk (*) and the number, after the variable declaration? As seen in 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

回答1:


The asterisk declares the variable as a fixed-length string, where the number indicates the length of the string:

http://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.

They may be required for an API call, see this question:

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.



来源:https://stackoverflow.com/questions/7293436/asterisks-in-variable-declarations-in-vb6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!