New to Excel VBA and I know I am missing something, but not sure what...
I have a module with this code;
[VBA]
Function AddNumbers(a As Integer) As Integer
Dim b As Integer
b = a + 2
End Function
[/VBA]
and a UserForm1 with this code:
[VBA]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
[/VBA]
and excel sheet with this:
[VBA]
Private Sub cmd_start_Click()
UserForm1.Show
End Sub
[/VBA]
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...