Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Textbox problem


Hello there, I`m trying to make a textbox that only accept numbers
including zero (0), I wrote a code, it work fine, but the only problem
is that this code
doesn`t accept zero witch is bad. Can you please send me a code that
accept only numbers?. Thanks.

‘************** Star code

Private Sub TextBox3_Change()

If TextBox3.Value < "" And Val(TextBox3.Value) = 0 Then

MsgBox "Unicamente se permiten valores numéricos", vbCritical,
"...::: Error :::..."

TextBox3.Value = ""

TextBox3.SetFocus

CommandButton1.Visible = False

CommandButton2.Visible = False

TextBox4.Visible = False

Else

CommandButton1.Visible = True

CommandButton2.Visible = True

TextBox4.Visible = True

End If

If Val(TextBox3.Value) Val(TextBox2.Value) Then

MsgBox "El número máximo permisible de piezas defectuosas no puede

superar a el de la muestra.", vbCritical, "...::: Error :::..."

TextBox3.Value = ""

TextBox3.SetFocus

TextBox4.Visible = False

End If

End Sub

‘*************** End Code

Thanks for your help I sorry about my English, I`m from Colombia South

America.


--
mondolfo
------------------------------------------------------------------------
mondolfo's Profile: http://www.excelforum.com/member.php...o&userid=17083
View this thread: http://www.excelforum.com/showthread...hreadid=544781

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Textbox problem

If Not(IsNumeric(TextBox3.Value)) Then...
--
- K Dales


"mondolfo" wrote:


Hello there, I`m trying to make a textbox that only accept numbers
including zero (0), I wrote a code, it work fine, but the only problem
is that this code
doesn`t accept zero witch is bad. Can you please send me a code that
accept only numbers?. Thanks.

€˜************** Star code

Private Sub TextBox3_Change()

If TextBox3.Value < "" And Val(TextBox3.Value) = 0 Then

MsgBox "Unicamente se permiten valores numéricos", vbCritical,
"...::: Error :::..."

TextBox3.Value = ""

TextBox3.SetFocus

CommandButton1.Visible = False

CommandButton2.Visible = False

TextBox4.Visible = False

Else

CommandButton1.Visible = True

CommandButton2.Visible = True

TextBox4.Visible = True

End If

If Val(TextBox3.Value) Val(TextBox2.Value) Then

MsgBox "El número máximo permisible de piezas defectuosas no puede

superar a el de la muestra.", vbCritical, "...::: Error :::..."

TextBox3.Value = ""

TextBox3.SetFocus

TextBox4.Visible = False

End If

End Sub

€˜*************** End Code

Thanks for your help I sorry about my English, I`m from Colombia South

America.


--
mondolfo
------------------------------------------------------------------------
mondolfo's Profile: http://www.excelforum.com/member.php...o&userid=17083
View this thread: http://www.excelforum.com/showthread...hreadid=544781


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Textbox problem


Try changing:

If TextBox3.Value < "" And Val(TextBox3.Value) = 0 Then

To:

If Not IsNumeric(TextBox3.Value) The

--
colofnatur
-----------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...fo&userid=3435
View this thread: http://www.excelforum.com/showthread.php?threadid=54478

Reply
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
Textbox Problem toocold[_21_] Excel Programming 4 April 18th 06 04:01 PM
Textbox problem Robert Couchman[_4_] Excel Programming 11 February 26th 04 02:01 PM
Textbox adding problem Todd Huttenstine[_3_] Excel Programming 11 February 10th 04 09:51 AM
TextBox SetFocus Problem Tom Ogilvy Excel Programming 1 September 12th 03 01:27 PM
Excel textbox problem numcrun Excel Programming 0 July 16th 03 10:05 AM


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

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

About Us

"It's about Microsoft Excel"