|
-
Jun 4th, 2009, 04:43 AM
#1
Thread Starter
Junior Member
[RESOLVED] the problem with variable in "if....end"
codes like below:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer = 3
Dim b As Integer = 7
Dim c As integer
Dim k As String
Dim x As Integer
If n > 1 Then
If x = 5 Then
k = "23"
End If
If x = 6 Then
k = "33"
End If
Else
k = "99"
End If
If b > 5 Then
c = b + k
Else
c = b - k
End If
textbox1.text = c
End Sub
when I run the codes above, error message indicated:
Variable k is used before it has been assigned a value.A null reference exception could result at runtime
pls,thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|