KEY COMBINATION TO INCREMENT ALPHA OR NUMERIC VALUE IN TEXTBOX

VB.NET 2003

I have a textbox  "txtLevel"

In the keydown event of my form  i need the following:

If a user  presses  Ctrl+Shift+F7

If the value in txtLevel is numeric ( that is 1-1000) then the number gets raised to the next number

i..e  If the value is  "3" then its gets raised to "4"

i.e. If the value is  "A"  then  it goes to "B"

If the value is "0" or null...then nothing happens

messagebox.show "No values to increment"


Thanks
fordraiders












LVL 3
FordraidersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Hi fordraiders,

Can you expound on the letter half of the problem?

Do you want the LENGTH of the letter to increase as well?

For example, "Y" --> "Z", but would "Z" --> "AA", and "AA" --> "AB"?

Here's another sequence:
AZX
AZY
AZZ
BAA
BAB
BAC

And another:
ZZX
ZZY
ZZZ
AAAA
AAAB
AAAC
0
nffvrxqgrcfqvvcCommented:
You could try to use some logic like this and you can edit to what you need.
If e.Control And e.Shift And e.KeyCode = Keys.F7 Then

            Dim arg As Char = TextBox1.Text

            If Char.IsLetter(arg) Then
                Dim value As Integer = AscW(arg)
                Select Case value
                    Case 65 To 89, 97 To 121
                        TextBox1.Text = ChrW(value + 1).ToString
                End Select
            End If

            If Char.IsNumber(arg) Then
                Dim value As Integer = CInt(TextBox1.Text)
                Select Case value
                    Case Is > 0 ' or Case 1 To 1000
                        value += 1
                        TextBox1.Text = value.ToString
                End Select
            End If

        End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FordraidersAuthor Commented:
IDLE MIND,  no
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.