LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default accept fractions from textbox

Thanks for the tip...
--
Gary''s Student - gsnu200788


"Bernie Deitrick" wrote:

Gary''s Student,

Evaluate is an excellent idea - much better than my using a range object -
but with a little extra code to clean things up, since evaluate doesn't like
commas...

Bernie

Sub TestIt()
Dim myValue As Double
myValue = FracToDec(" 1,230 5 \ 6")
MsgBox myValue
End Sub

Function FracToDec(ByVal Fraction As String) As Double
Fraction = Application.Trim(Fraction)
Fraction = Replace(Fraction, "\", "/")
Fraction = Replace(Fraction, " /", "/")
Fraction = Replace(Fraction, "/ ", "/")
Fraction = Replace(Fraction, ",", "")
FracToDec = Evaluate(Fraction)
End Function

"Gary''s Student" wrote in message
...
Make a Textbox (I used the Drawing Toolbar). Enter 3/4

Run the following:

Sub Macro1()
Dim s As String
ActiveSheet.Shapes("Text Box 1").Select
s = Selection.Characters.Text
MsgBox (Evaluate(s))
End Sub

Outputs .75
--
Gary''s Student - gsnu200788


"brianbanksia" wrote:

I cannot enter fractions in a TextBox and have them recognised as
numbers.

If IsNumeric(UserForm1.TextBox2.Value) = False Then 'Quantity
MsgBox "Choose NUMERIC quantity. Transaction cancelled!", , "Company
Name"
End If

I am having trouble getting this to work in Excel 2007; Vista whereas
works
Excel 2003 XP.

Is there a better way or is it a machine setting problem rather than
Excel
(eg Universal Date settings etc)
Thanks B




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How2 accept only numbers in userform textbox MARTY Excel Programming 9 January 5th 08 05:47 AM
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys Minitman[_4_] Excel Programming 0 February 22nd 05 08:50 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:43 PM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM


All times are GMT +1. The time now is 02:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"