Convert Simple Liberty Basic to VB.NET

  • Thread starter Thread starter Basil Fawlty
  • Start date Start date
B

Basil Fawlty

Hi everyone, I could use some help in converting a simple Liberty BASIC
program toa VB.NET 2003 SE program. I have built the simple form with a
label, text box and button, Under the button I have inserted the old
LIberty BASIC code. Now my problem is how to go about making the mod to the
code to fit VB's needs, but not loose the logic as it's sound. What should
I start doing at this point? Many thanks, 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
 
Add a text box to the form to input your word and a label to show your
reversed word. The user can enter his text in the text box and then in the
button.click event for the button, reverse your word (textbox.text) and set
the label.text property to the reversed word.

This should be enough info for you to get started on the right track.
 
Hi everyone, I could use some help in converting a simple Liberty BASIC
program toa VB.NET 2003 SE program. I have built the simple form with a
label, text box and button, Under the button I have inserted the old
LIberty BASIC code. Now my problem is how to go about making the mod to the
code to fit VB's needs, but not loose the logic as it's sound. What should
I start doing at this point? Many thanks, 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

Private Function IsPalindrome (ByVal TestString As String)
Dim Temp As String = TestString.ToLower ()
Dim chars() As Char = Temp.ToCharArray ()

Array.Reverse (chars)

Dim Reversed As New String (chars)

Return (Temp = Reversed)
End Function

Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

If (IsPalindrome (TextBox1.Text))
Label1.Text = String.Format ("The word {0} is a palindrome",
TextBox1.Text)
End If
End Sub
 
Tom Shelton said:
Private Function IsPalindrome (ByVal TestString As String)
Dim Temp As String = TestString.ToLower ()
Dim chars() As Char = Temp.ToCharArray ()

Array.Reverse (chars)

Dim Reversed As New String (chars)

Return (Temp = Reversed)
End Function

Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

If (IsPalindrome (TextBox1.Text))
Label1.Text = String.Format ("The word {0} is a palindrome",
TextBox1.Text)
End If
End Sub

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 linesof
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)

Next i

ReversedTextBox = s1

If UCase(s) = UCase(s1) Then

PalMsg = "The above IS a palindrome"

Else

PalMsg = "The above is NOT a palindrome"

End If

PalMsg = True

End Sub
 
Back
Top