• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

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












0
Fordraiders
Asked:
Fordraiders
1 Solution
 
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
 
FordraidersAuthor Commented:
IDLE MIND,  no
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now