467,912 Members | 1,517 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,912 developers. It's quick & easy.

Convert Simple Liberty Basic to VB.NET

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
Nov 21 '05 #1
  • viewed: 3392
Share:
3 Replies
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.

"Basil Fawlty" wrote:
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

Nov 21 '05 #2
On 2005-03-19, Basil Fawlty <Ba***************@NOSPAMyahoo.com> wrote:
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 [MVP]
Nov 21 '05 #3
"Tom Shelton" <ts******@YOUKNOWTHEDRILLcomcast.net> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
On 2005-03-19, Basil Fawlty <Ba***************@NOSPAMyahoo.com> wrote:
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 [MVP]


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
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by asj | last post: by
23 posts views Thread by Kenneth Osenbroch | last post: by
7 posts views Thread by Ish2000 | last post: by
reply views Thread by Basil Fawlty | last post: by
29 posts views Thread by Harlin Seritt | last post: by
10 posts views Thread by =?Utf-8?B?Um95?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.