糊弄的别过来,另再百度上看到
Private Sub Command1_Click()
'1^2+2^2+3^2+4^2+……+n^2>1000 //这句可以直接出现?
Dim sum, i
sum = 0: i = 0
Do While sum < 1000# //这是小于没错?还有sum可以直接使用?
i = i + 1
sum = sum + i * i
Loop
MsgBox "最小项数:" & i
End Sub
用VB计算S=1+2^2+2^3+…+2^10的代码
sub command1_click()dim i as integer for i = 100 to 200 if i mod 3 = 0 and i mod 5 = 0 then print i;end if next i end sub vb编程计算1-2+3-4+5-6……+-n,其中n由文本框输入 private sub command1_click()dim i%,k%,s k = 1 for i = 1 to ...
用VB编写下图的程序,急!!!后天就要交了!!程序能运行正确者追加50分...
Dim SZ1 As Integer, YSF(1 To 3) As String, SZ2 As Integer, YSFX As String, DAAN As Integer Private Sub Command1_Click()End End Sub Private Sub Command2_Click()Dim K As String, YSS DAAN = Val(Text3.Text)Text2(0).Text = Val(Text2(0).Text) + 1 If YSFX = "+...
VB中编写一个子过程,计算1*3+2*4+3*5+···+(n-2)*n的值
计算1*3+2*4+3*5+···+ n*(n+2)的值,比较合理!通常,n表示项数,而n*(n+2)表示通项公式,即:第1项是将n=1,代到n*(n+2)里得到的值,就是1*3 第2项是将n=2,代到n*(n+2)里得到的值,就是2*4 ...等等。当键盘输入n,表示求该式的前n项的和。比如输入3,...
如何用VB做一个简单计算器 要求实现加减乘除乘方开方功能
Case 1: Text1.Text = Data + Val(Text1.Text) Case 2: Text1.Text = Data - Val(Text1.Text) Case 3: Text1.Text = Data * Val(Text1.Text) Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.Text = Data \/ Val(Text1.Text) Case 5: Text1.Text...
VB代码 12个文字随机2个文字组合,不重复.
Dim a1(11) '这个程真的不太好编,要看就看死你 ,呵呵!!!四亿多个 Dim a2(10)Dim a3(9)Dim a4(8)Dim a5(7)Dim a6(6)Dim a7(5)Dim a8(4)Dim a9(3)Dim a10(2)For i = 1 To 12 'a(i)For j = 1 To 12 If j <> i Then x = x + 1 a1(x) = a(j) ...
做两个VB程序 简单题目
2.用VB编程序实现十进制与二进制之间的相互转化 代码:Private Sub Command1_Click() Text3.Text = "" Text4.Text = "0." n = Val(Text1.Text) Do While n > 0 Text3.Text = CStr(n Mod 2) + Text3.Text n = n \\ 2 Loop n = Val(Text2.Text) Do While...
如何用vb编一个程序:输入一个不多于5位的正整数,要求:1求出它是几位...
Private Sub Command1_Click()Dim wei()wei = Array("个", "十", "百", "千", "万")a = InputBox("输入一个不大于五位的整数")Print "这是一个"; Len(a); "位数。"For i = 1 To Len(a)Print wei(i - 1); "位是:"; Mid(a, Len(a) - i + 1, 1)Next End Sub ...
用VB编程计算1-2+3-4+5-6…±n的值,n由文本框输入
楼上的程序,个人认为有点小问题,修改如下:Private Sub Form_Click()Dim n As Integer Dim sum As Integer sum = 0 n = Val(InputBox("输入一个整数:"))sum = 0 For i = 1 To n '此处修改 sum = sum + (-1) ^ (i + 1) * i '此处修改 Next i Print sum End Sub ...
vb编写程序,输入正整数,显示1,1,2,3,5,8,13,21……
Private Sub Command1_Click()Dim a(), i, j As Longn = Val(InputBox("请输入Fibonacci数列的项数n(<=70)"))If n >= 3 And n <= 70 ThenList1.ClearReDim a(n)a(1) = 1a(2) = 1For i = 3 To n a(i) = a(i - 2) + a(i - 1)NextFor i = 1 To n List...
vb!急! 2. 编写一个程序,在文本框中任意输入一个自然数N,单击“计算...
2. 编写一个程序,在文本框中任意输入一个自然数N,单击“计算”按钮则将斐波那契数列的第N项显示在标签中,如图压缩包中所示。sy62.rar 3. 编写一个英文打字训练的程序,要求如下:(1)在文本框内随机产生30个字母的范文。(2)当焦点进人输入文本框时开始计时,并显示当时的时间。(3)在文本框...