De: Tim Zych Objet: Re: Fomatting Text Boxes Date : jeudi 21 octobre 1999 00:01 I extended the LIKE operator for the choices you gave; you can always add more. Private Sub CommandButton1_Click() dim x(5) As String dim txt As String x(0) = "###" x(1) = "##" x(2) = "#" x(3) = "###.#" x(4) = "##.#" x(5) = "#.#" for y = 0 to 5 if TextBox1.Text Like x(y) then msgbox ("OK"), vbOKOnly Exit Sub end if next msgbox ("You have not entered the proper format;" & vbCrLf & _ "please check the number again.") end Sub Tim G.Miller wrote in message ... >Tim, >Thanks for the help but it doesnt seem to work. Sorry if I wasn't clear >enough. >the number could be entered in as either ###, ##, #, ###.#, ##.#, #.# >........ >I can only seem to get 'Like' to reference one type of format. >What I have tried to do now is > >dim num as Single >num = TB_Number.value > >but when I try this, I get a run time error - 13 (type mismatch) if I type >anything but numbers in the Textbox. >How can I force the user to enter in numbers and avoiding fatal errors as >such? > >if entered correctly, this number will be added to a database set up on the >worksheet. It gets called for calculations so I really need it to be >numerical. Any ideas? > >Thanks, >Geoff > > >Tim Zych wrote in message >news:O4#wrfxG$GA.55@cppssbbsa04... >> Hello G.Miller: >> >> >> if TextBox1.Text Like "##0" then msgbox "OK", vbOKOnly >> msgbox TextBox1.Text >> >> >> Hope this helps. >> >> Tim >> >> >> G.Miller wrote in message ... >> >Hello, >> >I am using excel 97. I have a userform(dataform) with two textboxes on >it >> >(TB_name, TB_Number). >> >I would like to >> >a) run a check to insure that the user enters a number into TB_Number >> >b) force TB_name to be treated as text no matter is it is a number or >text >> > >> >now if I have a button (B_enter) on the same userform, would it be >> something >> >like... >> > >> >Private Sub B_enter_Click() 'CHECK VALIDITY OF INPUT >> >with dataform >> >if .TB_name.value = "" then >> > msgbox ("Please Enter name") >> > Exit Sub >> >Elseif .TB_Number.value = "" then >> > msgbox ("Please Enter Number") >> > Exit Sub >> > >> >Elseif format(.TB_Number.value, "##0") = false then >> > msgbox("Please Enter a Valid Number") >> > Exit Sub >> > >> >end if >> > >> >format(.TB_name) >> > >> >end Sub >> > >> > >> >> > >