Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

:135 ‫صفحه‬ 3 ‫سوال‬

:‫كد‬
Private Sub Command1_Click() 
   Dim a As Integer, b As Integer 
   a = Val(InputBox("Enter number a :")) 
   b = Val(InputBox("Enter number b :")) 
   If b <> 0 Then Form1.Print a \ b Else Form1.Print "not defined" 
End Sub 

:135 ‫صفحه‬ 4 ‫سوال‬


:‫كد‬
Dim yy0 As Integer, mm0 As Integer, dd0 As Integer 
Dim yy As Integer, mm As Integer, dd As Integer 
Dim y As Integer, m As Integer, d As Integer 
Private Sub Command1_Click() 
   yy0 = Val(Text1.Text) 
   mm0 = Val(Text2.Text) 
   dd0 = Val(Text3.Text) 
   dd = Day(Date) 
   mm = Month(Date) 
   yy = Year(Date) 
   Print yy, mm, dd 
   If dd < dd0 Then 
      mm = mm ­ 1 
      dd = dd + 30 
   End If 
   d = dd ­ dd0 
   If mm < mm0 Then 
      yy = yy ­ 1 
      mm = mm + 12 
   End If 
m = mm ­ mm0 
   If yy >= yy0 Then 
      y = yy ­ yy0 
   Else 
      MsgBox "not valid" 
      Exit Sub 
   End If 
   Print yy0, mm0, dd0 
   Print "sal="; y, "mah="; m, "rooz"; d 
End Sub 

:135 ‫صفحه‬ 5 ‫سوال‬


:‫كد‬
Dim a As Integer, b As Integer, c As Integer, delta As Integer 
Dim x1 As Single, x2 As Single 
Private Sub Command1_Click() 
   a = Val(Text1.Text) 
   b = Val(Text2.Text) 
   c = Val(Text3.Text) 
   delta = b ^ 2 ­ 4 * a * c 
   If delta >= 0 Then 
      x1 = (­b + Sqr(delta)) / (2 * a) 
      x2 = (­b ­ Sqr(delta)) / (2 * a) 
      MsgBox "x1=" + Str(x1) + "   " + "x2=" + Str(x2) 
    Else 
       MsgBox "Not Root" 
    End If 
End Sub 

:135 ‫صفحه‬6 ‫سوال‬


:‫كد‬
Dim citynam As String, cnam1 As String, cnam2 As String 
Dim max As Integer, min As Integer, dama As Integer 
Private Sub Command1_Click() 
   citynam = InputBox("Enter a city name : ") 
   dama = Val(InputBox("enter dama : ")) 
   cnam1 = citynam 
   cnam2 = citynam 
   max = dama 
   min = dama 
   For i = 2 To 10 
      citynam = InputBox("Enter a city name : ") 
      dama = Val(InputBox("enter dama : ")) 
      If min > dama Then 
         cnam1 = citynam 
         min = dama 
      End If 
      If max < dama Then 
           cnam2 = citynam 
           max = dama 
      End If 
    Next 
    Form1.Print "shahr="; cnam1, "minimum dama="; min 
    Form1.Print "shahr="; cnam2, "maximum dama="; max 
End Sub 

:135 ‫صفحه‬7 ‫سوال‬


:‫كد‬
Dim salary As Long 
Private Sub Command1_Click() 
   salary = Val(InputBox("Enter hoghogh : ")) 
   If salary <= 200000 Then 
      MsgBox salary 
      Exit Sub 
   End If 
   If salary <= 800000 Then 
      MsgBox salary ­ (salary ­ 200000) * 0.1 
      Exit Sub 
   Else 
      MsgBox salary ­ (salary ­ 800000) * 0.12 
      Exit Sub 
   End If 
End Sub 

:135 ‫صفحه‬8 ‫سوال‬


:‫كد‬
Dim n As Integer 
Private Sub Command1_Click() 
   n = Val(InputBox("Enter number n : ")) 
   Y1 = n Mod 10 
   n = n \ 10 
   Y2 = n Mod 10 
   n = n \ 10 
   y3 = n Mod 10 
   y4 = n \ 10 
   Form1.Print Y1 * 1000 + Y2 * 100 + y3 * 10 + y4 
End Sub 

:135 ‫صفحه‬9 ‫سوال‬


:‫كد‬
Dim k As Integer, c As Integer 
Private Sub Command1_Click() 
   k = 12 
   c = 0 
   Do While k < 100 
      c = c + 1 
      Form1.Print k 
      k = k + 3 
    Loop 
    Print "tedad="; c 
End Sub 

:135 ‫صفحه‬10 ‫سوال‬


:‫كد‬
Dim no As Byte 
Private Sub Command1_Click() 
   no = Val(InputBox("Enter a day of week : ")) 
   Select Case no 
      Case 1 
         MsgBox "Shanba" 
      Case 2 
         MsgBox "yek Shanba" 
      Case 3 
         MsgBox "dow Shanba" 
      Case 4 
         MsgBox "seh Shanba" 
      Case 5 
         MsgBox "chohar Shanba" 
      Case 6 
         MsgBox "panj Shanba" 
      Case 7 
         MsgBox "jomah" 
      Case Else 
         MsgBox "not valid" 
   End Select 
End Sub 

You might also like