how to trap? for example in my textfield i don't want my textfield to accept double data type only integer is accepted..i don't have any idea how to do it.. can someone here give me a clue...please a sample code.

You need to write a validation function for that and call the same in the lost focus of the control.

Edited 5 Years Ago by debasisdas: n/a

General declaration
Option Explicit

Private sub cmd_calculate_cllick()

dim radius as double
if IsNumeric(txtR.Text) then
  MsgBox("invalid input"
Exit Sub
End if
Public sub compute(ByVal radius As double)
  dim diameter,circumference as double,area as Double

end sub

what my teacher want is that the text field of the radius and the diameter would not accept a double data type to ?

Just a beginner all i want is ask some of idea's you experts have

Edited 3 Years Ago by mike_2000_17: Fixed formatting

add this to change event or lost focus of the text box.

if vaL(txtr.text) > 32767 then
msgbox( "out of range")
end if;
if (Trim(Like"*[!0-9]*") then

can u explain this to me what this kind of method i dont clearly understand it all i know "Like " is an operator in VB but it use and asteres and parenthesis
MsgBox("not valid")
end if
this method i use do work but...i forgot to trap, if the user will input greater than 32767 it has an error...i think ur method do work

I'm just a beginner please be patience if sometimes it hard for me to understanf right away

Edited 5 Years Ago by Nick Evan: Removed all the horrible tags

if you only want an integer

if isnumeric(txtr.text) then
   if int(txtr.text)=val(txtr.text) then
     msgbox "Only integers please"
     exit sub
   end if
   msgbox "Please enter a number"
   exit sub
end if

Edited 5 Years Ago by ChrisPadgham: n/a

This article has been dead for over six months. Start a new discussion instead.