: : Hi everyone, I could use some help in converting a simple Liberty BASIC
: : program to a VB.NET 2003 SE program. I know this is VB, I'm sure this is so simple for you guys that the .NET difference is inconsequential.
: : The LB program asks for the user to input a word, and the program will print to the screen the word in reverse and if the word is spelled the same in reverse and it is forward, then it will reply back saying that the word is a palindrome.
: : I have built a simple form with a label, text box for the word input, and a label and text box for the reverse spelling of the input word, another label and text box for the reply as to it being a palindrome as well as an OK button to fire it all off. Inside the OK button I have inserted my Liberty BASIC code. Now my problem is how to go about making the mods to the code to fit VB's needs, but not loose the logic as it's sound.
: : Many thanks for any and all help, Basil
: : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
: : System.EventArgs) Handles Button1.Click
: : input "Enter a word: "; s$
: : For i = Len(s$) To 1 Step -1
: : s1$ = s1$ + Mid$(s$, i, 1)
: : Next i
: : print "Reversed is: "; s1$
: : If s$ = s1$ Then
: : Print("The word " + s$ + " is a palindrome")
: : Else
: : End If
: : End Sub
: : End Class
: Visual Basic 6 has a function for this. I assume VB.NET has a similair function. In VB6: Reverse(String)
: So basically the code would be: (VB6)
: Text1.Text = "Word" 'Word input
: Text2.Text = Reverse(Text1.Text)
: If Text1.Text = Text2.Text Then
: MsgBox "It's a palindrome!"
: End If
: So VB.NET should have something alike... Something like strMyString.Reverse perhaps?
I'm just not quite getting it... below is the code I'm working with. I've made sure the properties of each text box has the right (name) to match the .vb coded values... and I still get compile errors. Based on the code below, 2 errors;Value of type 'System.Windows.Forms.TextBox' cannot be converted to 'String' & Value of type 'String' cannot be converted to
'System.Windows.Forms.TextBox' exist. they would be related to the lines of code: s = InputLine and the ReversedTextBox = s1. I seem to have a problem with the compiler if I leave the .TextBox items there, and removing them reduced the number of compiler errors.
I think I'm getting close though. --Basil
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s As String, i As Integer, s1 As String, PalMsg As String
PalMsg = False
s1 = ""
s = InputLine
For i = Len(s) To 1 Step -1
s1 = s1 & Mid(s, i, 1)
ReversedTextBox = s1
If UCase(s) = UCase(s1) Then
PalMsg = "The above IS a palindrome"
PalMsg = "The above is NOT a palindrome"
PalMsg = True