Variable Scoope Visual Basic .NET
Sabtu, 17 Oktober 2015
Edit
Kode pada modul: |
Module Module1 Public sNama As String End Module kode pada form: Public Class Form1 Private sKota As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click sNama = "Visual basic Net" TextBox1.Text = sNama End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click sKota = "Medan" TextBox1.Text = sKota End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim sNegara As String = "Indonesia" TextBox1.Text = sNegara End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click TextBox1.Text = snegara End Sub End Class Di bawah ini adalah gambar demo programnya:
sNegara dinyatakan error Name "snegara" is not declared.
Ini disebabkan variable sNegara yang dinyatakan dengan Dim sNegara As String = " |