如何在 Visual Basic 6if
中使用另一个 ?if
例如,在 C++ 中,我可以用 开始我的语句{
并用 结束它们,并且我可以在第一条语句}
中使用另一个。if
例如:
if m>3
{ .....
if a>5
{
......
}
else {....}
} else ........
…但在 Visual Basic 中没有{
}
或类似的东西
我想编写一个程序,从用户那里接收时间并从中减少 4:30!例如,当用户运行它时,它会问:在德黑兰几点钟了?和用户输入时间(例如 16:30)然后程序从它减少 4 小时 30 分钟!并打印:格林威治标准时间是:12:00!我会更新我的帖子并输入我的代码!请阅读!
Option Explicit
Private Sub Command1_Click()
Cls
Dim h As Integer, m As Integer, hm As Integer, mm As Integer, t As Integer
Dim fh As String, fm As String, fhm As String, fmm As String
t = InputBox("Enter time")
h = t \ 100
m = t Mod 100
Select Case h
Case 0 To 24
If m < 60 Then
If m >= 30 Then
hm = h - 4
mm = m - 30
If h < 10 Then fh = Format(h, String(2, "0")) Else fh = h
If m < 10 Then fm = Format(m, String(2, "0")) Else fm = m
If hm < 10 Then fhm = Format(hm, String(2, "0")) Else fhm = hm
If mm < 10 Then fmm = Format(mm, String(2, "0")) Else fmm = mm
Print
Print " Tehran Time is : "; fh; ":"; fm
Print
Print " GMT Time is : "; fhm; ":";
Else
hm = h - 5
mm = m + 30
If h < 10 Then fh = Format(h, String(2, "0")) Else fh = h
If m < 10 Then fm = Format(m, String(2, "0")) Else fm = m
If hm < 10 Then fhm = Format(hm, String(2, "0")) Else fhm = hm
If mm < 10 Then fmm = Format(mm, String(2, "0")) Else fmm = mm
Print
Print " Tehran Time is : "; fh; ":"; fm
Print
Print " GMT Time is : "; fhm; ":"; fmm
End If
End If
Case Else
Beep
Print
Print " Time is wrong !!! Try again "
End Select
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
End Sub