t caldwell
November 21st, 1999, 05:05 PM
I am still rather new at visual basic programming (being an Access2000 developer) and I cannot come up with a solution to the following problem :
I need to create a new string 5 digits in length from a another string of any length, and convert it to the new 5 digit string
based on the following conditions : The first digit of the new string is the first letter of the old string, and the last digit of the new string is a zero. The second, third and fourth strings are based on the following formula, if those letters are the following, then they are assigned the equivalent number:
A-C=1, D-F=2, G-I=3, J-L=4, M-O=5, P-R=6, S-U=7, V-X=8,Y-Z=9
So, given the old string "Manpower", the new string would be "M1560"
The following function is what I came up with, and, it does not work. I am still so new at this I just can't put all the pieces of string manipulation functions together yet, and I do so hope that one day I will be able to easily come up with the solution to a problem like this one ! I appreciate your help ! Please broaden my knowledge with your advice ! I thank you very much !
Terry Caldwell
t_caldwell@hotmail.com
Function GetAccountSuffix(Name) As Variant
Dim suffix As Variant, suffix1 As Variant, suffix5 As Variant, 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 As Variant
suffix1 = Mid(Name, 1, 5)
suffix5 = 0
suffix = Mid(Name, 2, 4)
Select Case suffix
Case A Or B Or C
suffix = 1
Case D Or E Or F
suffix = 2
Case G Or H Or I
suffix = 3
Case J Or K Or L
suffix = 4
Case M Or N Or O
suffix = 5
Case P Or Q Or R
suffix = 6
Case S Or T Or U
suffix = 7
Case W Or X Or Y
suffix = 8
Case Else
suffix = 9
Name = suffix1 & suffix & suffix5
End Select
End Function
I need to create a new string 5 digits in length from a another string of any length, and convert it to the new 5 digit string
based on the following conditions : The first digit of the new string is the first letter of the old string, and the last digit of the new string is a zero. The second, third and fourth strings are based on the following formula, if those letters are the following, then they are assigned the equivalent number:
A-C=1, D-F=2, G-I=3, J-L=4, M-O=5, P-R=6, S-U=7, V-X=8,Y-Z=9
So, given the old string "Manpower", the new string would be "M1560"
The following function is what I came up with, and, it does not work. I am still so new at this I just can't put all the pieces of string manipulation functions together yet, and I do so hope that one day I will be able to easily come up with the solution to a problem like this one ! I appreciate your help ! Please broaden my knowledge with your advice ! I thank you very much !
Terry Caldwell
t_caldwell@hotmail.com
Function GetAccountSuffix(Name) As Variant
Dim suffix As Variant, suffix1 As Variant, suffix5 As Variant, 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 As Variant
suffix1 = Mid(Name, 1, 5)
suffix5 = 0
suffix = Mid(Name, 2, 4)
Select Case suffix
Case A Or B Or C
suffix = 1
Case D Or E Or F
suffix = 2
Case G Or H Or I
suffix = 3
Case J Or K Or L
suffix = 4
Case M Or N Or O
suffix = 5
Case P Or Q Or R
suffix = 6
Case S Or T Or U
suffix = 7
Case W Or X Or Y
suffix = 8
Case Else
suffix = 9
Name = suffix1 & suffix & suffix5
End Select
End Function