Set length on DIM statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone tell me the syntax of a DIM statement where you want to define a
variable as fixed length? I've used it before but can't remember and I can't
locate it in the Help screens.

Thanks in advance
 
You can only do it with string variables:

Dim strName As String(20)

will limit the variable to 20 characters.
 
Dim MyString As String * 50

Example:

Public Sub ShowFixedLength()
Dim stf As String * 32 'Fixed length string.

stf = "Everything after the first 32 characters is lost."
Debug.Print stf
stf = "Has trailing spaces"
Debug.Print stf & "." 'Dot shows where spaces end.
End Sub
 
Oops. Allen and Klatuu are correct: it's String * 20, not String(20).

Sorry about that.
 
Back
Top