Kendall
10-08-2010, 04:58 PM
Hi All,
I'm new to VBA, so please bear with me a bit here:) I'm working on updating/maintaining a small project, and am having a bit of trouble with some string handling. Platform is Access 2000.
There is a function that reads the input into a text field on a form, and does different actions based on what the input is. The following are valid inputs:
"1"
"X"
"01" to "99"
"Blend1", "Blend2", "Blend3"
"Crew"
"IM" to "IO"
"SC" to "SD"
23 character alphanumeric scanned from barcode
The input is treated in the program as a string. Now, the 23 character string used to start with an M, but was changed to start with either "01" or "02". Currently the code is handling the input via a Select Case, along the lines of
Case "1"
//do something
Case "01" to "98"
//do something
Case "99"
//do something
Case "IM" to "IO"
//do something
Case "SC" to "SD"
//do something
Case "Blend1" to "Blend3"
//do something
Case "Crew"
//do something
Case Left(string) = "M"
//do something
However, since the 23 character string now starts with either "01" or "02", the Case enters at the "01" to "98" test (which is incorrect).
The codes "01" to "98" are contained in a table, so I could perform a lookup there.
I'm trying to come up with an intelligent way to re-write this function, and hopefully validate the inputs while I'm at it, but I'm new to VBA and can't quite come up with a good solution. Most everything I thought of seemed rather a kludge and I want to do this as correctly as possible so the next guy doesn't have the mess that I do:)
Sorry if the question is a bit vague, my brain is fried after a few hours:)
Thanks in advance for any help/suggestions; if my question wording sucks, let me know and I'll try to post it better!
Thanks,
Kendall
I'm new to VBA, so please bear with me a bit here:) I'm working on updating/maintaining a small project, and am having a bit of trouble with some string handling. Platform is Access 2000.
There is a function that reads the input into a text field on a form, and does different actions based on what the input is. The following are valid inputs:
"1"
"X"
"01" to "99"
"Blend1", "Blend2", "Blend3"
"Crew"
"IM" to "IO"
"SC" to "SD"
23 character alphanumeric scanned from barcode
The input is treated in the program as a string. Now, the 23 character string used to start with an M, but was changed to start with either "01" or "02". Currently the code is handling the input via a Select Case, along the lines of
Case "1"
//do something
Case "01" to "98"
//do something
Case "99"
//do something
Case "IM" to "IO"
//do something
Case "SC" to "SD"
//do something
Case "Blend1" to "Blend3"
//do something
Case "Crew"
//do something
Case Left(string) = "M"
//do something
However, since the 23 character string now starts with either "01" or "02", the Case enters at the "01" to "98" test (which is incorrect).
The codes "01" to "98" are contained in a table, so I could perform a lookup there.
I'm trying to come up with an intelligent way to re-write this function, and hopefully validate the inputs while I'm at it, but I'm new to VBA and can't quite come up with a good solution. Most everything I thought of seemed rather a kludge and I want to do this as correctly as possible so the next guy doesn't have the mess that I do:)
Sorry if the question is a bit vague, my brain is fried after a few hours:)
Thanks in advance for any help/suggestions; if my question wording sucks, let me know and I'll try to post it better!
Thanks,
Kendall