由于您提到了使用 VB 编程,因此我将使用 Visual Basic 来回答您的问题。
首先,我们需要声明一个变量来存储人口总数,并将其初始值设为 15 亿。接下来,我们需要声明一个变量来存储每年人口增长的比例,并将其初始值设为 1%。
在 Visual Basic 中,我们可以使用如下代码来完成以上 *** 作:
Copy codeDim population As Double = 1500000000Dim growthRate As Double = 001
接下来,我们需要使用一个循环,每次循环计算一年后的人口总数,并判断是否已经超过 20 亿。如果超过了,则通过 Msgbox 输出超过 20 亿所需的年数。
在 Visual Basic 中,我们可以使用如下代码来完成以上 *** 作:
Copy codeDim numYears As Integer = 0Do
numYears = numYears + 1
population = population + population growthRateLoop Until population > 2000000000MsgBox("人口总数超过 20 亿所需的年数:" & numYears)
上面的代码中,我们声明了一个变量 numYears 用来存储超过 20 亿所需的年数。每次循环,我们都将 numYears 加 1,然后计算一年后的人口总数。如果人口总数超过了 20 亿,则通过 Msgbox 输出超过 20 亿所需的年数,然后退出循环。
1 工程
2 属性
3 通过
4 form1show
5 SelStart
7 x mod 5=0 or x mod 9 =0
Dim CountY%, CountC%
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim C$
C = Chr(KeyAscii)
If "A" <= C And C <= "Z" Then
Select Case C
Case "A", "E", "I", "O", "U"
CountY = CountY + 1
Case Else
CountC = CountC + 1
End Select
End If
If KeyAscii = 13 Then
Print "元音字母有"; CountY; "个"
Print "其他字母有"; CountC; "个"
End If
End Sub
Option Explicit
Private Sub Command1_Click()
List1Clear
List3Clear
Dim i As Integer, n As Integer, nj As Integer, sj As Integer, so As Integer
sj = 0: so = 0: nj = 0
For n = 0 To 9
i = Val(List2List(n))
If i Mod 2 <> 0 Then
List1AddItem i
sj = sj + i
nj = nj + 1
Else
List3AddItem i
so = so + i
End If
Next n
Label4Caption = nj & "个奇数和=" & sj
Label5Caption = 10 - nj & "个奇数和=" & so
End Sub
Private Sub Form_Load()
Dim i As Integer
Randomize
For i = 0 To 9
List2AddItem Int(Rnd 100)
Next i
End Sub
Private Sub Command1_Click(Index As Integer)
Dim a As Integer
Randomize
a = Rnd 3
'0代表剪刀 1代表石头 2代表布
Select Case a
Case 0
If Index = 2 Then Text1Text = "你输了"
If Index = 0 Then Text1Text = "平手"
If Index = 1 Then Text1Text = "你赢了"
Case 1
If Index = 0 Then Text1Text = "你输了"
If Index = 1 Then Text1Text = "平手"
If Index = 2 Then Text1Text = "你赢了"
Case 2
If Index = 1 Then Text1Text = "你输了"
If Index = 2 Then Text1Text = "平手"
If Index = 0 Then Text1Text = "你赢了"
End Select
Command1(0)Enabled = False
Command1(1)Enabled = False
Command1(2)Enabled = False
End Sub
Private Sub Command2_Click()
Text1Text = ""
Command1(0)Enabled = True
Command1(1)Enabled = True
Command1(2)Enabled = True
End Sub
Private Sub Command3_Click()
End
End Sub
第一题:① n
第二题:
Private Sub Command1_Click()
Timer1Interval = 500
Timer1Enabled = True
End Sub
Private Sub Command2_Click()
Timer1Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim r As Integer, g As Integer, b As Integer
r = Int(Rnd 256)
g = Int(Rnd 256)
b = Int(Rnd 256)
Text1BackColor = RGB(r, g, b)
End Sub
a = InputBox("1", "2")
print a
a1=InputBox("1", "2")
a2=InputBox("1", "2")
a3=InputBox("1", "2")
msgbox("z" & a1+a2+a3 & "avg" & (a1+a2+a3)/3,"xh xm")
以上就是关于VB的编程题,急!拜托各位大神了全部的内容,包括:VB的编程题,急!拜托各位大神了、VB编程题目求教、vb编程题:1. 编写程序实现如下功能:如图一 2. 编写程序实现如下功能:等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)