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


Hi,

I have a textbox in which only a 6 digit date in the format DDMMY
should be entered. I've got the code for if it is blank, and if it i
less than or greater than 6 digits in length. All I need now is to b
able to 'listen' for these 'illegal' symbols. Any ideas?

Cheer

--
Josep

-----------------------------------------------------------------------
Joseph's Profile: http://www.excelforum.com/member.php...nfo&userid=563
View this thread: http://www.excelforum.com/showthread.php?threadid=27811

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Detecting Symbols in Textbox

Joseph,
The following code is for a textbox on a form with a command button...

Option Explicit

Private Sub CommandButton1_Click()
Dim intYear As Integer, intMonth As Integer, intDay As Integer
Dim dteEnteredDate As Date
On Error Resume Next

If Len(TextBox1.Text) = 6 Then
intDay = CInt(Left(TextBox1.Text, 2))
intMonth = CInt(Mid(TextBox1.Text, 3, 2))
intYear = CInt(Right(TextBox1.Text, 2))

If intDay 0 And intMonth 0 And intYear 0 Then
dteEnteredDate = DateSerial(intYear, intMonth, intDay)
MsgBox Format(dteEnteredDate, "dd mmmm, yyyy")
Unload Me
Else
MsgBox "Bad date: " & TextBox1.Text
End If
ElseIf TextBox1.Text < "False" Then
MsgBox "Date must contain six characters (DDMMYY). You entered: " &
TextBox1.Text
End If
End Sub

Private Sub TextBox1_Change()
Dim i As Integer
For i = 1 To Len(Me.TextBox1.Text)
If Not IsNumeric(Mid(Me.TextBox1.Text, i, 1)) Then
MsgBox "Your last enterd character, """ & Mid(Me.TextBox1.Text,
i, 1) & """, is not a number.", vbExclamation, "Joseph's application"
Me.TextBox1.Text = Left(Me.TextBox1.Text, Len(Me.TextBox1.Text)
- 1)
End If
Next
End Sub

I hope you can use some of it.
Dale Preuss


"Joseph" wrote:


Hi,

I have a textbox in which only a 6 digit date in the format DDMMYY
should be entered. I've got the code for if it is blank, and if it is
less than or greater than 6 digits in length. All I need now is to be
able to 'listen' for these 'illegal' symbols. Any ideas?

Cheers


--
Joseph


------------------------------------------------------------------------
Joseph's Profile: http://www.excelforum.com/member.php...fo&userid=5637
View this thread: http://www.excelforum.com/showthread...hreadid=278119


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
Symbols on the keyboard are not the symbols on the screen.... Lisha Excel Discussion (Misc queries) 2 May 22nd 10 07:29 AM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:43 PM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM
How to move cursor from one textbox control to another textbox con KMoore007 Excel Programming 0 September 16th 04 02:47 PM


All times are GMT +1. The time now is 01:07 AM.

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

About Us

"It's about Microsoft Excel"