
Private Sub Command1_Click()
Dim x As Integer
x=Val(Text 1.Text)
Select Case
Case Is>=90
Text2.Text=“A”
Case Is>=80
Text2.Text=“B”
Case Is
Text2.Text=“C”
Case Is>=60
Text2. Text=“D”
Case Else
End Select
End Sub
x=10
if x>=10:
Value=3*x
else:
Value=5*X+ 10
x=4
ifx==5:
print("优秀")
elif x==4:
print("良好")
elif x==3:
print("及格")
else:
print("不及格")
i=1
sum=0
while i<=20:
if I %2==0:
sum=sum-i
else:
sum=sum+i
i +=1
print (sum)
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Private Sub Command2_Click()
Dim a As Single, b As Single, c As Single
Dim x1 As Single, x2 As Single, det As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
det = ‘(根的判别式b2-4ac)
Select Case det
Case Is > 0
x1 = (-b + Sqr(det)) / (2 * a)
x2 = (-b - Sqr(det)) / (2 * a)
Text4.Text = "方程有两个实数根" & " x=" & Str(x1) & " x=" & Str(x2)
Case Is = 0
Text4.Text = "方程有两个相等的实数根 x=" & Str(x1)
Case
Text4.Text = "此方程无实数根"
End Sub
Private Sub Command1_Click()
Dim x As Integer
x = Val(Text1.Text)
Select Case x
Case Is >= 450
Text2.Text = "优秀"
Case Is >= 400
Text2.Text = "良好"
Case Is > 350
Text2.Text = "中等"
Case Is >= 300
Text2.Text = "及格"
Case Else
Text2.Text = "不及格"
End Select
End Sub
语法错误:
该程序运行后,若在文本框中输入350,则输出为:
Dim G As Integer
Dim M As Integer
Input “输入重量 G = ”; G
If then
M=0.65*G
Else
M=
End if
Print “运费为:”; M
下列程序的功能是:当x<50时,y=0.8×x;当50≤x≤100时,y=0.7×x;当x>100时,输入的数据超出范围。请填空。
Private Sub Command1_Click()
Dim x As Single
x=InputBox("请输入x的值!")
Case x < 50
y=0.8 * x
Case 50 To 100
Print "输入的数据超出范围!"
End Select
Print x, y
End Sub
在VB中有三种程序结构,其中的分支结构中有一种多分支结构,可以针对多种情况进行编程。在编写移动的坦克游戏中,其中有这一段代码
|
1 Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer) 2 Select Case KeyCode 3 Case 37 4 Image1.Picture = LoadPicure(App.Path& "\pic\tank1.jpg") 5 If Image1.Left - 20 < 0 Then 6 Image1.Left=0 7 Else 8 Image1.Left= Image1.Left-20 9 End If |
from microbit import *
while True:
water_ level =pinl. read_ analog () #将p1引脚的模拟值设为变量“water_ level”
if water_ level<300:
display. show (Image. SAD)
else:
display. show (Image. HAPPY)
If a<=70 Then i=1
If a>70 Then i=2
Print i
以上程序段的执行结果为2。
x=0
a=8
if a<9:
x=9
print (x)
x=4 y=3
if x>y:
print(x)
else:
print(y)
屏幕上输出的内容是()
| a=10 b=5 if(a<<b): print("a比b小") |
chengji = int( input("请输入百分成绩"))
if chengji >= 85:
print("成绩为:优秀")
else:
print("成绩为:良好")
a=int(input("请输入1-20的整数"))
b=15
if a==b:
print("恭喜你,猜对了")
else:
if a>b:
print("很遗憾,猜大了")
else:
print("很遗憾,猜小了")

