Function
Function
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Function

  1. #1
    New Member
    Join Date
    Jan 2002
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I am a new user of Excel and writing VBA functions. I am trying to write a function that looks at user input from a form text box and makes sure it is not blank and that it is text, not numbers. I am trying to use a select case statement, but can't get it to work.

  2. #2
    Board Regular
    Join Date
    Aug 2003
    Location
    England
    Posts
    5,533
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Function

      
    Hello,

    I know you posted this a long time ago, but I have only recently registered, and am trying to work my way through the unanswered posts, to gain as much experience as possible. I don't know if you need this any more, but I think I have come up with a solution.

    Option Explicit
    Dim CURRENT As String, enter As String

    Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    CURRENT = TextBox1.Text
    If KeyAscii > 47 And KeyAscii < 66 Then
    enter = MsgBox("TEXT ONLY", vbOKOnly, "TEXT ONLY")
    KeyAscii = 0
    End
    End If
    End Sub

    Private Sub TextBox1_LostFocus()
    If TextBox1.Text = "" Then
    enter = MsgBox("EMPTY TEXT BOX", vbOKOnly, "EMPTY")
    End If
    End Sub

    Hope this helps.
    -------------------------
    Hope this is helpful.
    -------------------------

    Have been away from the forum for quite a while, but am now back.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com