ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Asterisk after String Delcaration???? (https://www.excelbanter.com/excel-programming/427618-asterisk-after-string-delcaration.html)

Excel Monkey[_2_]

Asterisk after String Delcaration????
 
I just came across some string variable declarations that I have not seen
before and was wondering if someone could explain what they mean. I have
never seen the asterisk used before like this. Is this a VBA thing? Lastly
does it translate into VB.Net?

Dim strBuffer()As String * 1

and then within a
Private Type udtWIN32_FIND_DATA
cFileName As String * 260
cAlternat As String * 14
End Type

Thanks

Nigel[_2_]

Asterisk after String Delcaration????
 
Hi Rick
Just to illuminate this further, can you see where such a construct would be
used? It is so rare to see in my experience.

Thanks

--

Regards,
Nigel




"Rick Rothstein" wrote in message
...
That is how you declare a fixed length string. For example, this..

Dim strVar As String * 10

declares strVar as a String variable that always has 10 characters... the
string is always padded (if necessary) with blank spaces to ensure the
variable contains 10 characters. However, if the variable has not yet been
initialized (that is, nothing has ever been assigned to it), then it is
defaulted to a string composed of 10 characters with an ASCII value of
0... but once something has been assigned to the variable, it will (from
then on) be blank space padded even if the empty string is assigned to it
later on. So, if you did this...

strVar = "ABCDE"

then strVar would equal those characters with 5 blanks spaces after them.
If you then later on did this...

strVar = ""

then strVar would contain 10 blank spaces. The example you gave of this...

Dim strBuffer()As String * 1

declares a dynamic array of Strings that will be made up of elements that
are all one character long.

--
Rick (MVP - Excel)


"Excel Monkey" wrote in message
...
I just came across some string variable declarations that I have not seen
before and was wondering if someone could explain what they mean. I have
never seen the asterisk used before like this. Is this a VBA thing?
Lastly
does it translate into VB.Net?

Dim strBuffer()As String * 1

and then within a
Private Type udtWIN32_FIND_DATA
cFileName As String * 260
cAlternat As String * 14
End Type

Thanks





All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com