我是 VB 的新手。我读了一本书并遵循它的代码
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim Wrap As String
Wrap = Chr(13) & Chr(10)
Dim i As Integer
For i = 1 To 4
PictureBox1.Image = System.Drawing.Image.FromFile("C:\face0" & i & ".ico")
MsgBox("Click for next face")
Next
End Sub
End Class
有用。但是,我尝试调整代码以使 Wrap 成为整个 form1 可用的变量。我做了以下,但它不起作用。为什么?
Public Class Form1
Dim Wrap As String
Wrap = Chr(13) & Chr(10)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim i As Integer
For i = 1 To 4
PictureBox1.Image = System.Drawing.Image.FromFile("C:\face0" & i & ".ico")
MsgBox("Click for next face")
Next
End Sub
End Class