Spidermans_DarkSide - MSP, VSIP
Hi,
Please see the code comments below.
Regards,
S_DS
___________________________________
Public
Class Form1
'Moved so the Button_Click Sub also "sees" these
'these two variables.
Dim aatt As Integer
Dim adef As Integer
Sub monSet(ByVal arg)
'Do one set of DIM statements at the top of your SUB
Dim lvl_ As Integer
Dim aspd As Integer
If arg = "rat" Then
'These two DIM'ed outside the SUB to make the variables
'GLOBAL to all the SUBroutines and Functions within the FORM.
'Dim aatt As Integer
'Dim adef As Integer
aatt = 1
adef = 1
lvl_ = 1
aspd = 1
End If
If arg = "thief" Then
Dim aatt As Integer
'No need to DIM any variable twice within a Sub
'Do all the local declarations at the top.
'Dim adef As Integer
aatt = 17
adef = 13
lvl_ = 15
aspd = 21
End If
End Sub
'...
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
monSet("thief")
'Use ToString to change a variable TYPE
'for use in a MessageBox.
'Try to use "&" to join strings and "+" for addition too,
'it makes it clearer that you are joining strings.
MessageBox.Show(aatt.ToString &
", " & adef.ToString)
End Sub
End
Class