Contoh Source Code Visual Studio 2008
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = 1 To 10
ListBox1.Items.Add(I)
Next
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
ListBox1.Items.Add(I)
Next
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 2 = 0 Then
ListBox1.Items.Add("Bil Genap " & I)
Else
ListBox1.Items.Add("Bil Ganjil " & I)
End If
ListBox1.Items.Add(I)
Next
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim I As Integer = 1
ListBox1.Items.Clear()
Do While I <= 10
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox1.Text)
Do While I <= Val(TextBox2.Text)
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox1.Text)
Do While I <= Val(TextBox2.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
I = I + 1
Loop
End Sub
End Class
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = 1 To 10
ListBox1.Items.Add(I)
Next
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
ListBox1.Items.Add(I)
Next
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 2 = 0 Then
ListBox1.Items.Add("Bil Genap " & I)
Else
ListBox1.Items.Add("Bil Ganjil " & I)
End If
ListBox1.Items.Add(I)
Next
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim I As Integer = 1
ListBox1.Items.Clear()
Do While I <= 10
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox1.Text)
Do While I <= Val(TextBox2.Text)
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox1.Text)
Do While I <= Val(TextBox2.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
I = I + 1
Loop
End Sub
End Class
Public Class Form2
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
TextBox1.Focus()
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
TextBox3.Focus()
End If
End Sub
Sub gabung()
ListBox1.Items.Add(Trim(TextBox1.Text) & " " & Trim(TextBox3.Text) & " " & Trim(TextBox2.Text))
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
Call gabung()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call gabung()
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
TextBox1.Focus()
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
TextBox3.Focus()
End If
End Sub
Sub gabung()
ListBox1.Items.Add(Trim(TextBox1.Text) & " " & Trim(TextBox3.Text) & " " & Trim(TextBox2.Text))
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
Call gabung()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call gabung()
End Sub
Kondisi dan Pengulangan ( Looping )
Dalam microsoft studio 2008 ada program untuk suatu kondisi dan juga juga ada program untuk suatu pengulangan (looping).
Kondisi
Sintax :
Ifthen
A
B
End if
Ket :
• Jika kondisi benar maka akan menjalankan A, jika salah maka akan menjalankan B
Pengulangan (looping)
• For - Next
For i=a to n
-
-
Next
Ket :
Looping batas a sampai n , a harus type data integer.
• Do While
Do while
-
-
Loop
Ket :
Jika kondisi benar maka akan akan looping, kalau salah maka akan berhenti.
Variabel dilihat dari fungsi dan penggunaannya, di bagi 3 :
1. Variabel publik adalah variabel yang bisa dgunakan atau bisa di baca dalam 1 project ( semua form )
co : Public A As Integer pembuatannya di modul
2. Variabel general adalah variabel yang bisa digunakan hanya dalam 1 form saja, tetapi bs digunakan dalam semua class.
co : DIM kelas As Stringpembuatannya di class form/dipaling atas
3. Variabel lokal adalah variabel yang bisa digunakan dalam class-nya sendiri/ dalam 1 method saja.
co: DIM NPM As String
Ket :
Jika kita membuat variabel lokal, tetapi tidak kita gunakan, maka variabel itu akan menjadi sebuah kesalahan
Contoh instruksi Pengulangan (looping) yang ada di visual studio 2008 :
Dim I As Integer
ListBox1.Items.Clear()
(Untuk membersihkan)
For I = 1 To 10
(Untuk looping)
ListBox1.Items.Add(I)
(Untuk menambahkan)
Next
Ket :
Akan menjalankan looping sesuai programmer, sudah mematok loopingnya 1 sampai 10
Program akan mengerjakan setelah kita aksi
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
ListBox1.Items.Add(I)
Next
Ket :
Akan menjalankan looping sesuai kemauan si user, setelah menginputkan angkanya
Val : Untuk mengubah dr type teks/String ke numeric
Kondisi
Sintax :
If
A
B
End if
Ket :
• Jika kondisi benar maka akan menjalankan A, jika salah maka akan menjalankan B
Pengulangan (looping)
• For - Next
For i=a to n
-
-
Next
Ket :
Looping batas a sampai n , a harus type data integer.
• Do While
Do while
-
-
Loop
Ket :
Jika kondisi benar maka akan akan looping, kalau salah maka akan berhenti.
Variabel dilihat dari fungsi dan penggunaannya, di bagi 3 :
1. Variabel publik adalah variabel yang bisa dgunakan atau bisa di baca dalam 1 project ( semua form )
co : Public A As Integer pembuatannya di modul
2. Variabel general adalah variabel yang bisa digunakan hanya dalam 1 form saja, tetapi bs digunakan dalam semua class.
co : DIM kelas As Stringpembuatannya di class form/dipaling atas
3. Variabel lokal adalah variabel yang bisa digunakan dalam class-nya sendiri/ dalam 1 method saja.
co: DIM NPM As String
Ket :
Jika kita membuat variabel lokal, tetapi tidak kita gunakan, maka variabel itu akan menjadi sebuah kesalahan
Contoh instruksi Pengulangan (looping) yang ada di visual studio 2008 :
Dim I As Integer
ListBox1.Items.Clear()
(Untuk membersihkan)
For I = 1 To 10
(Untuk looping)
ListBox1.Items.Add(I)
(Untuk menambahkan)
Next
Ket :
Akan menjalankan looping sesuai programmer, sudah mematok loopingnya 1 sampai 10
Program akan mengerjakan setelah kita aksi
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
ListBox1.Items.Add(I)
Next
Ket :
Akan menjalankan looping sesuai kemauan si user, setelah menginputkan angkanya
Val : Untuk mengubah dr type teks/String ke numeric
PENGULANGAN
Pengulangan adalah suatu instruksi dalam pemrograman agar sekelompok perintah dilaksanakan dengan berulang sampai dengan suatu kondisi terpenuhi.
Berikut contoh pengulangan dalan visual studio 2008
1. For
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = 1 To 10
ListBox1.Items.Add(I)
Next
End Sub
2. Do While
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim I As Integer
ListBox1.Items.Clear()
Do While I <= 10
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
3. For Next
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
ListBox1.Items.Add(I)
Next
End Sub
4. Do While Next
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
5. For Ganjil & Genap
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 2 = 0 Then
ListBox1.Items.Add("Bil Genap " & I)
Else
ListBox1.Items.Add("Bil Ganjil " & I)
End If
Next
End Sub
7. For 3,-6,9,-12, 15
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
Next
End Sub
8. Do While 3,-6,9,-12, 15
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
I = I + 1
Loop
End Sub
Berikut contoh pengulangan dalan visual studio 2008
1. For
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = 1 To 10
ListBox1.Items.Add(I)
Next
End Sub
2. Do While
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim I As Integer
ListBox1.Items.Clear()
Do While I <= 10
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
3. For Next
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
ListBox1.Items.Add(I)
Next
End Sub
4. Do While Next
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
5. For Ganjil & Genap
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 2 = 0 Then
ListBox1.Items.Add("Bil Genap " & I)
Else
ListBox1.Items.Add("Bil Ganjil " & I)
End If
Next
End Sub
7. For 3,-6,9,-12, 15
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
Next
End Sub
8. Do While 3,-6,9,-12, 15
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
I = I + 1
Loop
End Sub
Sabtu, 16 April 2011
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call gfor()
Call dowhile()
End Sub
sub gfor()
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 3 = 0 And I Mod 7 > 0 Then
ListBox1.Items.Add(I)
End If
Next
End Sub
Sub dowhile()
Dim A As Integer
ListBox2.Items.Clear()
A = Val(TextBox1.Text)
Do While A <= Val(TextBox2.Text)
If Microsoft.VisualBasic.Right(A, 1) = 3 Then
ListBox2.Items.Add(A)
End If
A = A + 1
Loop
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
End Class
PENGULANGAN
Pengulangan adalah suatu instruksi dalam pemrograman agar sekelompok perintah dilaksanakan dengan berulang sampai dengan suatu kondisi terpenuhi.
Berikut contoh pengulangan dalan visual studio 2008
1. For
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = 1 To 10
ListBox1.Items.Add(I)
Next
End Sub
2. Do While
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim I As Integer
ListBox1.Items.Clear()
Do While I <= 10
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
3. For Next
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
ListBox1.Items.Add(I)
Next
End Sub
4. Do While Next
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
5. For Ganjil & Genap
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 2 = 0 Then
ListBox1.Items.Add("Bil Genap " & I)
Else
ListBox1.Items.Add("Bil Ganjil " & I)
End If
Next
End Sub
7. For 3,-6,9,-12, 15
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
Next
End Sub
8. Do While 3,-6,9,-12, 15
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
I = I + 1
Loop
End Sub
Berikut contoh pengulangan dalan visual studio 2008
1. For
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = 1 To 10
ListBox1.Items.Add(I)
Next
End Sub
2. Do While
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim I As Integer
ListBox1.Items.Clear()
Do While I <= 10
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
3. For Next
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
ListBox1.Items.Add(I)
Next
End Sub
4. Do While Next
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
ListBox1.Items.Add(I)
I = I + 1
Loop
End Sub
5. For Ganjil & Genap
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 2 = 0 Then
ListBox1.Items.Add("Bil Genap " & I)
Else
ListBox1.Items.Add("Bil Ganjil " & I)
End If
Next
End Sub
7. For 3,-6,9,-12, 15
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox2.Text) To Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
Next
End Sub
8. Do While 3,-6,9,-12, 15
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim I As Integer
ListBox1.Items.Clear()
I = Val(TextBox2.Text)
Do While I <= Val(TextBox3.Text)
If I Mod 3 = 0 And I Mod 2 = 0 Then
ListBox1.Items.Add(I * -1)
Else
If I Mod 3 = 0 Then
ListBox1.Items.Add(I)
End If
End If
I = I + 1
Loop
End Sub
Contoh Program Vb.net
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call gfor()
Call dowhile()
End Sub
sub gfor()
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 3 = 0 And I Mod 7 > 0 Then
ListBox1.Items.Add(I)
End If
Next
End Sub
Sub dowhile()
Dim A As Integer
ListBox2.Items.Clear()
A = Val(TextBox1.Text)
Do While A <= Val(TextBox2.Text)
If Microsoft.VisualBasic.Right(A, 1) = 3 Then
ListBox2.Items.Add(A)
End If
A = A + 1
Loop
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
End Class
sOURCE : sasuke-manga.blogspot.com
Tidak ada komentar:
Posting Komentar