|
||
|
|
#1 (permalink) |
|
Forum Expert
|
Hey! I was wondering about code to convert hex into a digit... I've been trying, yet i've found no way to fix any digits like "G" and "M" and "$" and such... They cause the stuff to give an error.
Here's what i'm talking about... Text1 and Text2 are the text boxes. Scenario 1: -User imputs a HEX code (like FB34) into Text1 -I use command Text2.Text = Int(Text1.Text) -Output should go into Text2... -Say user 'messed up' and typed "GB34" into Text1... -Program crashes... Scenario 2: -User imputs NUMBERS into Text1... -Messes up, types something like 103Y -Text2 is supposed to make that HEX... It's too stupid to do so... -Tries to use command Text2.Text = Hex(Text1.TexT) and crashes... I don't know how to remove that, i've tried this tutorial on removing certain characters from a string, but that didn't work :\ So, if anyone knows... then please aid! lol -Aiden
__________________
|
|
|
|
|
|
#2 (permalink) |
|
Join Date: Nov 2003
Posts: 164
|
easiest way is to simply ignore the offending characters. try this:
Scenario 1: Text2.Text = Val("&h" + Text1.Text) Scenario 2: Text2.Text = Hex(Val(Text1.Text)) In both cases, if it encounters an invalid character, it simply stops parsing the string. so if i put 1G3 and tried to convert it to hex, it would only return 1. and if I typed FX in to convert to int, it would only return 15 If this isn't what you're looking for, or you can't make it work, let me know... |
|
|
|
|
|
#3 (permalink) | |
|
Forum Expert
|
Quote:
![]() ![]()
__________________
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|