M
musicalhacksaw
Dear Programmers,
I seem to be running into difficulty running the following program in Excel.
I have made a Command Button and called it cmdBegin and given its caption as Begin in the properties window.
However upon pressing the button in the Excel Spreadsheet, it returns as an error (a yellow arrow) that the first line:
Private Sub cmd Begin_click()
is not defined.
I can't get the Book's website as it seems the UK branch is defunct, though they tout their website on the back cover and in the text a lot, they don't actually specify what or where it is, and how it might be accessed.
Anyhow I thought I might try Googlegroups for help.
This is the text of the program in question:-
----------------------------------------------------------------------------
Private Sub cmdBegin_Click( )
Dim userName As String
Dim firstName As String
Dim lastName As String
Dim strLength As Integer
Dim spaceLoc As Integer
'----------------------------
'Collect user name, find the space between
'first and last names, and separate the names.
'------------------------------------------------
userName = InputBox("Enter your first and last name.", "Name")
spaceLoc = InStr(1,userName," ")
firstName = Left(userName, spaceLoc - 1)
'-----------------------------------------------
'Output to the worksheet
'-----------------------------------------------
Range("C3").Value = firstName
strLength = Len(firstName)
Range("C4").Value = strLength 'length of first name
strLength = Len(userName)
lastName = Mid(userName, spacelLoc + 1, strLength - spaceLoc)
Range("C5").Value = lastName
strLength = Len(lastName)
Range("C6").Value = strLength
Range("C7").Value = UCase(userName)
Range("C8").Value = LCase(userName)
Range("C9").Value = StrConv(userName, vbProperCase)
Range("C10").Value = StrReverse(userName)
Range("C11").Value = lastName & ", " & firstName
End Sub
I seem to be running into difficulty running the following program in Excel.
I have made a Command Button and called it cmdBegin and given its caption as Begin in the properties window.
However upon pressing the button in the Excel Spreadsheet, it returns as an error (a yellow arrow) that the first line:
Private Sub cmd Begin_click()
is not defined.
I can't get the Book's website as it seems the UK branch is defunct, though they tout their website on the back cover and in the text a lot, they don't actually specify what or where it is, and how it might be accessed.
Anyhow I thought I might try Googlegroups for help.
This is the text of the program in question:-
----------------------------------------------------------------------------
Private Sub cmdBegin_Click( )
Dim userName As String
Dim firstName As String
Dim lastName As String
Dim strLength As Integer
Dim spaceLoc As Integer
'----------------------------
'Collect user name, find the space between
'first and last names, and separate the names.
'------------------------------------------------
userName = InputBox("Enter your first and last name.", "Name")
spaceLoc = InStr(1,userName," ")
firstName = Left(userName, spaceLoc - 1)
'-----------------------------------------------
'Output to the worksheet
'-----------------------------------------------
Range("C3").Value = firstName
strLength = Len(firstName)
Range("C4").Value = strLength 'length of first name
strLength = Len(userName)
lastName = Mid(userName, spacelLoc + 1, strLength - spaceLoc)
Range("C5").Value = lastName
strLength = Len(lastName)
Range("C6").Value = strLength
Range("C7").Value = UCase(userName)
Range("C8").Value = LCase(userName)
Range("C9").Value = StrConv(userName, vbProperCase)
Range("C10").Value = StrReverse(userName)
Range("C11").Value = lastName & ", " & firstName
End Sub