Value assignment

In previous posts you have seen how variable values are assigned and in this text I will look at Variant data type, basic arithmetic as well as some other operations that we can use to calculate desired expressions. I think it will be especially helpful for you to find out how to set the fixed length strings, and how to merge more of them into one.
Variant is a universal data type. VBA uses it every time you declare a variable or declare it without determining the type. It is used as a temporary solution while you are developing code, and you are not sure which type of data you will use. Although your programs will work without a type declaration, it’s always up to you to do it-so you save your memory and your code is more understandable!

VBA supports basic computational operations: addition (+), subtraction (-), multiplication (*), and division (/). In addition, they are also supported by power (^). In the expressions we write, we can, as operands, state the values as well as the names of the variables, so that all the listed options are correct:

Dim, b, c, d As Integer
a = 2
b = 2
c = a ^ b
d = c + 2

When we declare variables that contain text, we can determine their length. Creating a fixed-length string is done by, after the name of the type, the star and the whole number indicating the length. For example:

Dim fs As String * 10
fs = “0123456789”

If we want to merge two strings this will be done using the “+” sign, as if we were collecting them. See how this works in the case:

Dim s1, s2, s3 As String
s1 = “First”
s2 = “Other”
s3 = s1 + “” + s2