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.

can you please give an example what ur trying to say please..

Lets see the code that you are working on.

General declaration
Option Explicit

Private sub cmd_calculate_cllick()

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

end sub

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

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

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

if you only want an integer

if isnumeric(txtr.text) then
   if int(txtr.text)=val(txtr.text) then
     OK
   else
     msgbox "Only integers please"
     exit sub
   end if
else
   msgbox "Please enter a number"
   exit sub
end if
commented: Useful +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.