User FAQs


1) What is the best way to check for an empty string ?
Always check the length of the string using the LEN function.
Avoid comparing with an empty string ("") as this requires 6 bytes of memory.

If VBA.Len(myString) = 0 Then 

2) What is the best way to assign an empty string ?
Always assign your string to vbNullString when you need to empty the contents.
Avoid using an empty string ("") as this is slower and takes up more memory.
Zero-Length String ("") - Is an actual string literal and has a size of 6 bytes.
vbNullString - Is a special character that denotes an empty string which is equivalent to zero.

Dim myString As String 
myString = VBA.Constants.vbNullString

3) How would you declare a Variable Length String ?

Dim myString As String 

4) How would you declare a Fixed Length String with 10 characters ?
A fixed length string is padded with null characters CHR(10) when it is declared.
The CHR returns the character with the corresponding ANSI number.

Dim myString As String * 10 

5) How would you check the last 2 characters in a string ?

Dim myString As String 
myString = "someText"
If (Mid(myString, Len(myString) - 1) = "xt") Then
End If

6) How would you check for specific characters in a string ?
The Like Operator can be used to compare two strings and provide pattern matching.

If (sFirstName Like "a?b*" = True) Then 
End If


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext