Text box with two buttons

5 pts.
Tags:
TextBox
VB
Visual Basic
I need to have a Text box with two buttons , one up and one down . when I use the up button it turns from 1 to 5 and when i use down it turns from 5 to 1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hello Mahan M, hereafter an example:

<pre>
Sub ButtonDown
Select Case Text1.text
Case “1″
Text1.text = “2″

Case “2″
Text1.text = “3″

Case “3″
Text1.text = “4″

Case “4″
Text1.text = “5″

Case Else
MsgBox “Cannot add more”,VbOkOnly+VbInformation
End Select
End Sub

Sub ButtonUp
Select Case Text1.text
Case “1″
MsgBox “Cannot subtract more”,VbOkOnly+VbInformation

Case “2″
Text1.text = “1″

Case “3″
Text1.text = “2″

Case “4″
Text1.text = “3″

Case “5″
Text1.text = “4″

End Select
End Sub

</pre>

Bye

Don’t forget to visit my blog: <a href=”http://itknowledgeexchange.techtarget.com/it-support/”>If it has a plug, it’s IT stuff!!</a>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • BobBeechey
    Here is a more robust alternative for ButtonUp which includes wrap around
    Private Sub ButtonUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Select Case TextBox1.Text
                Case "1", "2", "3", "4"
                    TextBox1.Text = CInt(TextBox1.Text) + 1
                Case Else
                    TextBox1.Text = "1"
            End Select
        End Sub
    
    ButtonDown would be similar.
    750 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following