View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default TRICKY ONE FOR YOU CODEMASTERS!!!

On Tue, 25 Nov 2003 03:46:49 -0800, "Dean Knox"
wrote:

A Challenge for you all, I desperately need help.

I would like code that will manipulate a number upon entry
into a text box.

When entering a number eg 487654321 and pressing enter, it
checks the 1st digit, and depending on the digit replces
it with a number, i.e a 4 is a D/, a 8 is a A/. But if the
first digit is a 7 it keeps it as a 7/. Basically the
ability for me to define what the first digit will be
replaced with.

It also checks the last digit and puts a dash before it so
ending in 1 becomes -1, ending in 4 becomes -4 apart from
when it ends in * then I want it to become -10.

A few examples

4123456789 --- D/12345678-9
412345678* --- D/12345678-10
8876543210 --- A/87654321-0
7232323232 --- 7/23232323-2

Hope someone is bright enough to help

Thanks

Dean Knox


Maybe this will give you some ideas?

================
txt = InputBox("Input a Number: ")
first = Left(txt, 1)
last = Right(txt, 1)
txt = Mid(txt, 2, Len(txt) - 2)


Select Case first
Case Is = "4"
first = "D/"
Case Is = "8"
first = "A/"
Case Is = "7"
first = "7/"
End Select

If last = "*" Then last = "10"
last = "-" & last

MsgBox (first & txt & last)
=================


--ron