مکانی برای بیان مشکلات و رفع مشکلات دانشجویان رشته کامپیوتر دانشگاه سیرجان
برای دوستانی که SMS داده بودند که پاسخ سئوالات رو در متن وبلاگ بذارم.
Sub Question5()
Dim S As Integer
Dim N As Integer
Dim I As Integer
Dim F As Integer
S = 3
For N = 3 To 100
For I = 2 To Int(N / 2)
If N Mod I = 0 Then
F = 1
Exit For
Else
F = 0
End If
Next
If F = 0 Then
S = S + N
End If
Next
MsgBox "Result = " & S
End Sub
Sub Question6()
Dim Str As String
Dim InvStr As String
Str = InputBox("Enter Sample Text")
For I = Len(Str) To 1 Step -1
InvStr = InvStr & Mid(Str, I, 1)
Next
MsgBox "Str: " & Str & Chr(10) & "Inv: " & InvStr
End Sub
Sub Question7()
Dim I As Integer
Dim J As Integer
Dim Tmp As Variant
Sheet2.Select
For I = 3 To 20
For J = I + 1 To 20
If Cells(J, 1) < Cells(I, 1) Then
Tmp = Cells(I, 1)
Cells(I, 1) = Cells(J, 1)
Cells(J, 1) = Tmp
Tmp = Cells(I, 2)
Cells(I, 2) = Cells(J, 2)
Cells(J, 2) = Tmp
End If
Next
Next
End Sub
Sub Question8()
Load UserForm1
UserForm1.Show
End Sub
Function IsFirst(Num As Integer)
' Question9
Dim N As Integer
For N = 2 To Num / 2
If Num Mod N = 0 Then
IsFirst = False
Exit Function
End If
Next
IsFirst = True
End Function
Sub Question10()
Dim A As Double
Dim B As Double
Dim Res As Double
Dim Sign As String
A = InputBox("Enter 1st Number:")
B = InputBox("Enter 2nd Number:")
Sign = InputBox("Enter Sign:")
Select Case Sign
Case "+"
Res = A + B
Case "-"
Res = A - B
Case "*"
Res = A * B
Case "/"
Res = A / B
End Select
MsgBox A & " " & Sign & " " & B & " = " & Res
End Sub
Sub Question11()
Dim Pass As String
For I = 1 To 3
Pass = InputBox("Enter Password:")
If Pass = "abc123" Then
Load UserForm1
UserForm1.Show
Exit Sub
Else
If I < 3 Then
MsgBox "Wrong Password" & Chr(10) & "You Can Enter " & 3 - I & " Password"
Else
Application.Quit
End If
End If
Next
End Sub
برچسب:
نویسنده: آرش کاوه