residentevil190
21st July 2012, 21:06
เป็นโปรแกรมที่หา จำนวนเฉพาะ2-100 และแสดผลใน textbox1 ในรูปแบบ เช่น 2,3,5 แสดงผลเป็น 3
Public Class Form1
Private Sub Form1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim A As Integer
Dim B As Boolean
Dim S As String
Const N = 100
For A = 2 To N
B = True
If A Mod 2 = 0 Then
B = False
ElseIf A Mod 3 = 1 Then
B = False
ElseIf A Mod 5 = 1 Then
B = False
ElseIf A Mod 7 = 1 Then
B = False
End If
If B Then S = S & Space(1) & A
Next
TextBox1.Text = S
End Sub
End Class
Public Class Form1
Private Sub Form1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim A As Integer
Dim B As Boolean
Dim S As String
Const N = 100
For A = 2 To N
B = True
If A Mod 2 = 0 Then
B = False
ElseIf A Mod 3 = 1 Then
B = False
ElseIf A Mod 5 = 1 Then
B = False
ElseIf A Mod 7 = 1 Then
B = False
End If
If B Then S = S & Space(1) & A
Next
TextBox1.Text = S
End Sub
End Class