I have a sub with two variables in a module. When called from the form, the second variable triggers the error "“Variable 'ala1' is used before it has been assigned a value. A null reference exception could result at runtime”. The result is a blank textbox. Would appreciate your help to find where my code is not correct. Here is my code:
Module1
Dim N10, N02b, A6, N07 As Double
Public Sub AxlPos(ByVal axl As Double, ByVal axla As String)
If axl > (N10 - N02b / 1000) * modCos(A6) + N07 Then
axla = "in section 1"
ElseIf axl > (N10 - N02b / 1000) * modCos(A6) Then
axla = "in section 2"
ElseIf axl > (N10 / 1000) * modCos(A6) Then
axla = "in section 3"
Else
axla = "in section 4"
End If
End Sub
Form1
Dim N10, N02b, A6, N07, al1 As Double
Dim ala1 as string
Private Sub btnSolve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSolve.Click
axlpos(al1,ala1)
Txtala1.Text = ala1
End sub