Hello Everyone, I wanted to ask what methods are better to use to carryout this function: I want to convert a textstrings in the following. EXAMPLES: ---------------------- FROM: AB1204 TO: 12'-4" FROM: AB0909 TO: 9'-9" Basically, I have a 4 digit number representing feet and inches. I think I have figured a method out by "bullying" the textstring using IF, THEN, LEFT. RIGHT, and MID functions. IF/THEN for feet less than 10 feet, etc.. I was thinking there must be a better way to do this. Any suggestions, code, example, etc. is grreatly appreciated. Throught this NewsGroup, I have learned much. Thank you, Dan
You're in luck... you don't need to bully the textstring's, the VAL function will take care of the values less than 10.... if your format is always 4-digit, padded with zeroes (and always integers), you could just use: dim too as string, from as string from="AB1204" too = Format(Val(Mid(from, 3, 2))) & "'-" & Format(Val(Mid(from, 5, 2))) & """" msgbox too HTH, James
AWESOME! I knew there must be a better way, and I learned about a new function. Thank you very much, Dan
Hi James, Curious about the use of val function I seem to get the same from too = Format(Mid(from, 3, 2)) & "'-" & Format(Mid(from, 5, 2)) & """" as from your line using val I didn't try every possible input value though It seems from the help description that it only eliminates alpha characters which in this case according to the specs is taken care of by the format of the input string ??? tia Mark
I'm old school... I'm used to the Format$() function, which required a numeric parameter. So you had to go from string "09" to number 9 to string "9". The Format() function can apparently take a number OR a string value. I didn't know it could do that. James
NP... I think I still like the old school way, though. I'm not a big fan of Variants -- if I'm not even sure what type of variable I'm passing to a function, how likely is it that I know it has a valid value? An example.... I was curious what would happen if I sent it a string that was semi-numeric, so I tried Format("5.45a") thinking I'd get an error or "5.45". The result was "5:45:00 AM". In hindsight, it makes sense, but how many other unexpected answers are there lurking out there? Just my opinion..... James