Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by NevSoFly
at 2024-11-30 21:45:21
Point:500 Replies:2 POST_ID:828857USER_ID:10
Topic:
Microsoft Visual Basic.Net;;
In the below select case statement I am checking to see if the character in a string is alphabetic.
Select Case char Case "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" Do somethingEnd Select 1:2:3:4:
What I would like to know is if there is a simpler way of doing this, like:
case "a" to "z"
or
if char="a" to "z"
Accepted Solution
Expert: Robert Schutt replied at 2024-12-01 02:20:24
250 points EXCELLENT
Actually, your own first suggestion is perfectly valid:
However, there is a more generic way to do this and it includes letters with accents and the likes so not just "a" to "z" but also "é" for example:
Dim [char] As Char = TextBox1.Text.Substring(0, 1).ToLower() If Char.IsLetter([char]) Then ' ... End If 1:2:3:4:
Note that I used [char] to make it a valid variable name from your code example, and "Char.IsLetter" refers to a static method in the Char class.
Assisted Solution
Expert: duncanb7 replied at 2024-11-30 23:59:02
250 points EXCELLENT
Just example and partial code only, you can change e.KeyChar for your char or method variable
Hope understand your question completely. If not , please pt it out
Duncan
Hope understand your question completely. If not , please pt it out
Duncan
Dim KeyAscii As Integer KeyAscii = Asc(e.KeyChar) Select Case KeyAsciicase 65 to 90 ''for capital ALPHABET A-Zcase 97 to 122 'lower case a-zcase else 1:2:3:4:5:6: