1 Replies - 785 Views - Last Post: 25 September 2011 - 09:52 AM Rate Topic: -----

#1 Shana Cole  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-September 11

Create a user interface that displays the full name.

Posted 25 September 2011 - 09:00 AM

Create a user interface that the user can enter first name, middle initial and last name; when clicking the New button it will display the Full Name. This is my source code. When I compiled it, it says that Variable Not Defined. Please do help me with this. Your response(s) would be highly appreciated.

Option Explicit
Dim strFull As String


Private Sub cmdExit_Click()
Unload Me
End Sub

Private Function PCase(strVar As String) As String
PCase = UCase(Mid(strVar, 1, 1)) & LCase(Mid(strVar, 2, Len(strVar)))
End Function

Private Sub cmdNew_Click()
strFull = PCase(txtFirst.Text) & "" & _
        UCase(Mid(txtMiddle.Text, 1, 1)) & "" & _
        PCase(txtLast.Text)
lblFull.Caption = strFull
End Sub

Private Sub cmdReset_Click()
    txtFirst.Text = ""
    txtMiddle.Text = ""
    txtLast.Text = ""
    lblFull.Caption = ""
    txtFirst.SetFocus
End Sub


This post has been edited by Martyr2: 25 September 2011 - 09:44 AM
Reason for edit:: Please use code tags in the future, thanks! :)


Is This A Good Question/Topic? 0
  • +

Replies To: Create a user interface that displays the full name.

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,286
  • Joined: 18-April 07

Re: Create a user interface that displays the full name.

Posted 25 September 2011 - 09:52 AM

No need to define strFull at the top, define it right in the cmdNew_click event. But other than that, I don't see any immediate problems. Which line is it telling you is undefined? Another tip is to use "ByVal" when it comes to defining arguments for a function... Private Function PCase(ByVal strVar as String).

:)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1