View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Franz Verga Franz Verga is offline
external usenet poster
 
Posts: 459
Default Difficulty restricting characters

"kartune85" ha
scritto nel messaggio
...

I've used the following code to try and restrict certain characters to a
textbox:

Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc(".")
If InStr(1, Me.TextBox1.Text, ".") 0 Then
KeyAscii = 0
End If
End Select
End Sub

The period is not the only character I'm trying to restrict but it is
one of them. Whenever I've tried to use 'Select Case', the code never
seems to do anything... at all. The Textbox2 is used as the savename so
I can't allow any weird characters to get typed in.

Can anyone help me out regarding this?


Hi Kartune,

Instead of a text box to input the filename, you could try to use the Excel
Save As window:

Application.Dialogs(xlDialogSaveAs).Show


--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy