Lunes, Enero 9, 2012

basic2 : using listbox

you can declare outside or inside the method  the variable
if you gonna use again the variable declare it outside method

Inside Method:
Public Class Form1



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Integer
        a = TextBox1.Text
        ListBox1.Items.Add(a)
    End Sub
End Class


Outside Method :

Public Class Form1
 Dim a As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       
        a = TextBox1.Text
        ListBox1.Items.Add(a)
    End Sub
End Class


this is the code

add this in button.
Dim a As Integer
        a = TextBox1.Text
        ListBox1.Items.Add(a)

Walang komento:

Mag-post ng isang Komento