Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
This is because in order to use a function like CLng or CInt or CSng the value you pass into the function must be numeric. If you leave any of the textboxes blank then this throws an error as the function (CSng etc) cannot convert an empty string into a numeric value. So you need to check the values of the textboxes before you try to check them. You can use code like: if (vba.len(textbox1.value) 0 and vba.len(textbox2.value) 0 and vba.len(textbox3.value) 0) then If (vba.isnumeric(textbox1.value) and vba.isnumeric(textbox1.value) and vba.isnumeric(textbox1.value) ) then ' ALL OK, so check if values ad up else ' not numeric - is it a text value msgbox "please enter numbers only in the fields", vbexclamation+vbokonly end if else msgbox "Please fill each field", vbexclamation+vbokonly end if HTH Philip "Lucifix" wrote: Philips foruma works just well, but I get error if I leave all fields empty. Do you have any idea to fix this? Run-time error '13'. Type mismatch -- Lucifix ------------------------------------------------------------------------ Lucifix's Profile: http://www.excelforum.com/member.php...o&userid=29179 View this thread: http://www.excelforum.com/showthread...hreadid=495452 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Simple Calculation Not Working | Excel Discussion (Misc queries) | |||
PLEASE HELP--going crazy with a simple calculation | Excel Worksheet Functions | |||
Need help with a simple Time calculation | Excel Worksheet Functions | |||
Need help with a simple Time calculation | Excel Discussion (Misc queries) | |||
error in simple calculation? | Excel Discussion (Misc queries) |