Có thể bạn quan tâm
Yêu cầu: Tìm các ước chẵn, các ước lẻ từ 1 đến N (N nhập từ bàn phím)
Mô phỏng:

Các ước chẵn, các ước lẻ
CODE:
Private Sub Command1_Click() Label3.Caption = "" Dim N As Double N = Abs(Val(Text1.Text)) If N = 0 Then Label3.Caption = "Mçi sè nguyªn ®Òu lµ íc cña 0" Else For i = 1 To N If i Mod 2 = 0 Then If N Mod i = 0 Then Label3.Caption = Label3.Caption + Str(i) End If End If Next End If End Sub Private Sub Command2_Click() Label3.Caption = "" Dim N As Double N = Abs(Val(Text1.Text)) If N = 0 Then Label3.Caption = "Mçi sè nguyªn ®Òu lµ íc cña 0" Else For i = 1 To N If i Mod 2 <> 0 Then If N Mod i = 0 Then Label3.Caption = Label3.Caption + Str(i) End If End If Next End If End Sub Private Sub Label4_Click() Dim theWeb As String theWeb = "https://levantoan.com" Call Shell("explorer.exe " & theWeb, vbNormalFocus) End Sub
Code Visual basic
Download về tham khảo
Chúc các bạn thành công ^^
- Bình luận