I am using VB 98
Write a program which will ask the user to enter a sentence. At the click of a “remove first word” button the program will print the first word of the sentence in a picture box and replace the sentence in the input text box with the sentence without the first word. (In this way if the user enters a 5 word sentence and hits the “remove first word” button 5 times, the sentence will be reduced to nothing and 5 words will be printed in the picture box)
Private Sub cmdRemove_Click()
Dim strSentence As String
Dim intSpace As Integer
Dim strFirstPart As String
Dim strSecondPart As String
Dim strExtra As String
strSentence = Trim(txtSentence.Text)
intSpace = InStr(strSentence, " ")
strFirstPart = Left(strSentence, intSpace - 1)
strSecondPart = Mid(strSentence, intSpace)
strExtra = Mid(strSecondPart, Len(intSpace))
txtSentence.Text = strExtra
picOutput.Print (strFirstPart)
End Sub
My code works until the last word...then it crashes
Thanks
2007-10-28
12:43:16
·
3 answers
·
asked by
Supreme_edge
2
in
Computers & Internet
➔ Programming & Design