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

Hi all,

Am all most finished my MedEx XLS and found troubles when trying to delete
rows that had a numeric character as the first character (Unsure why).

Regardless, I figured that to ensure some protocol, the first character
could NOT be a numeric character.

The following code works, but it calls the TextBox1_Change() when I attempt
to alter its value. This results in the MsgBox appearing twice.

Any suggestions to solve this apreciated.

TIA
Cameron
-----------------------------------------------------------
Code:
Private Sub TextBox1_Change()
If Len(TextBox1.Text) 0 And IsNumeric(VBA.Left(TextBox1.Text, 1)) =
False Then
If Len(TextBox2.Text) 0 Then
If Len(TextBox3.Text) 0 Then
ContinueButton.Enabled = True
Else
ContinueButton.Enabled = False
End If
Else
ContinueButton.Enabled = False
End If
Else
MsgBox "Docors Names generally don't start with numbers.", _
vbOKOnly, "Incorrect Details !!"
TextBox1.Text = ""
TextBox1.SetFocus
ContinueButton.Enabled = False
End If
End Sub
-----------------------------------------------------------


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Controlling Input

The first occurence of the message box happens when someone enters a number
as the first "character." The second occurence is due to you again changing
the text box with the command:

TextBox1.Text=""

which fires the change event a second time due to Len(TextBox1.Text) not
being greater than zero.

I changed the code to the following:
------------------------------------
If Len(TextBox1.Text) 0 And IsNumeric(VBA.Left(TextBox1.Text, 1)) =
False Then

------------------------------------
If Len(TextBox1.Text) = 0 And IsNumeric(VBA.Left(TextBox1.Text, 1)) =
False Then

------------------------------------

HTH

--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winne
the Pooh
"Cameron" wrote in message
...
Hi all,

Am all most finished my MedEx XLS and found troubles when trying to delete
rows that had a numeric character as the first character (Unsure why).

Regardless, I figured that to ensure some protocol, the first character
could NOT be a numeric character.

The following code works, but it calls the TextBox1_Change() when I

attempt
to alter its value. This results in the MsgBox appearing twice.

Any suggestions to solve this apreciated.

TIA
Cameron
-----------------------------------------------------------
Code:
Private Sub TextBox1_Change()
If Len(TextBox1.Text) 0 And IsNumeric(VBA.Left(TextBox1.Text, 1)) =
False Then
If Len(TextBox2.Text) 0 Then
If Len(TextBox3.Text) 0 Then
ContinueButton.Enabled = True
Else
ContinueButton.Enabled = False
End If
Else
ContinueButton.Enabled = False
End If
Else
MsgBox "Docors Names generally don't start with numbers.", _
vbOKOnly, "Incorrect Details !!"
TextBox1.Text = ""
TextBox1.SetFocus
ContinueButton.Enabled = False
End If
End Sub
-----------------------------------------------------------




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Controlling Input

You have to set a flag that controls your code. For example:


Dim Working as Boolean

Private Sub TextBox1_Change()
If Not Working Then
If Len(TextBox1.Text) 0 And IsNumeric(Left(TextBox1.Text, 1)) = False
Then
If Len(TextBox2.Text) 0 Then
If Len(TextBox3.Text) 0 Then
ContinueButton.Enabled = True
Else
ContinueButton.Enabled = False
End If
Else
ContinueButton.Enabled = False
End If
Else
Working = True
MsgBox "Docors Names generally don't start with numbers.", _
vbOKOnly, "Incorrect Details !!"
TextBox1.Text = ""
TextBox1.SetFocus
ContinueButton.Enabled = False
Working = False
End If
End If
End Sub


--
Jim Rech
Excel MVP


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
Controlling Userforms harrysfan New Users to Excel 1 August 30th 06 12:47 PM
Controlling Sequence HS Excel Discussion (Misc queries) 0 March 15th 05 02:15 PM
Controlling Tab Oders John Excel Programming 1 February 12th 04 01:27 AM
Controlling VBA MWE[_3_] Excel Programming 2 January 13th 04 07:23 PM
Controlling the mouse Brian Sharf Excel Programming 1 July 21st 03 08:24 AM


All times are GMT +1. The time now is 04:58 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"