d=20 End Select
Select Case months Case 1, 3, 5, 7, 8, 10, 12 days = 31 Case 4, 6, 9, 11 days = 30 Case 2 If years Mod 400 = 0 Or (years Mod 4 = 0 And years Mod 100 <> 0) Then days = 29 Else days = 28 End If
For…Next 语句
❖ For…Next 语句
在循环次数已知的情况下,采用 For…Next语句实现循环 结构是比较合适的选择。For…Next语句的格式如下: For <循环变量>=初值 To 终值 [Step 步长]
<语句>
[Exit For] <语句> Next <循环变量> 例:计算累加和:S=1+2+3+4+…+n (P75) 例:计算水仙花数 (P77) 如153,153=13+53+33 例:判断素数 (P77) for 2 to sqr(n) 例:计算Fibonacci数列 (P78) if i mod 5=0 then print
VbNo
MsgBox函数的返回值
Private Sub Command1_Click() Dim expS1$, expS2$, expN%, Response% expS1 = "是否继续?" expN = vbYesNo + vbCritical + vbDefaultButton2 expS2 = "MsgBox 信息显示窗口" Response = MsgBox(expS1, expN, expS2) If Response = vbYes Then Text1.Text = "您按下的按钮是""是""" Else Text1.Text = "您按下的按钮是""否""" End If