I wanted to get familiar with the built-in functions of VB, specifically, the len()
function.
However, I think this may not be the right way to concatenate a string
with a char
.
Also, it may interest you that the error list says,
"Warning 1 Variable 'reverse' is used before it has been assigned a value. A null reference exception could result at runtime."
I executed the program but it ran fine. Here's the code:
Sub Main()
Dim a As String
Console.WriteLine("Enter the value of the string you want to reverse: ")
a = Console.ReadLine()
Dim reverse As String
Dim temp As Char
Dim str As Integer
str = Len(a)
For x = str To 1 Step -1
temp = Mid(a, x)
reverse = reverse + temp
Next x
Console.WriteLine(reverse)
Console.ReadKey()
End Sub
I'm still learning this language and so far it's been really fun to make small programs and stuff.