paul_0722
06-28-2008, 03:51 PM
New to Excel VBA and I know I am missing something, but not sure what...
I have a module with this code;
Function AddNumbers(a As Integer) As Integer
Dim b As Integer
b = a + 2
End Function
and a UserForm1 with this code:
Public Sub cmd_submit_Click()
Dim a As Integer
Dim b As Integer
a = txt_input.Value
AddNumbers (a)
lbl_text.Caption = b
End Sub
and excel sheet with this:
Private Sub cmd_start_Click()
UserForm1.Show
End Sub
When I click my worksheet button, the userform1 shows up, I input a number and press submit button, but the lbl.text.caption always shows "0" and not the number "b" (numbers added together) as I expected.
I suspect I have the dim statements mixed up but I cannot seem to get it right
Any help for a newbie appreciated...
I have a module with this code;
Function AddNumbers(a As Integer) As Integer
Dim b As Integer
b = a + 2
End Function
and a UserForm1 with this code:
Public Sub cmd_submit_Click()
Dim a As Integer
Dim b As Integer
a = txt_input.Value
AddNumbers (a)
lbl_text.Caption = b
End Sub
and excel sheet with this:
Private Sub cmd_start_Click()
UserForm1.Show
End Sub
When I click my worksheet button, the userform1 shows up, I input a number and press submit button, but the lbl.text.caption always shows "0" and not the number "b" (numbers added together) as I expected.
I suspect I have the dim statements mixed up but I cannot seem to get it right
Any help for a newbie appreciated...