knrt.net
当前位置:首页 >> VB编程:n由inputBox函数输入变量s的值在窗体上输... >>

VB编程:n由inputBox函数输入变量s的值在窗体上输...

n=inputbox("请输入n(n>=2)") dim s as double dim i as integer for i=2 to n s=s + 1/i*(i-1) next print s

Sub test() Dim s As String Dim i As Integer Dim x() As String Dim xSum As Single s = InputBox("请输入3个数字,用分号(;)隔开:", "Hi") x = Split(s, ";") For i = 0 To 2 xSum = xSum + x(i) Next MsgBox "这三个数字的平均值为 " & x...

Private Sub Command1_Click() Dim n, i, S As Long n = InputBox("请输入自然数n的值", "期末考试第一题") For i = 1 To n Step 2 S = i + i Next Label1.Caption = "1到" & n & "之间奇数的和为:" & S End Sub Private Sub Command2_Click() ...

Private Sub Command1_Click() a = InputBox("请输入数字a") b = InputBox("请输入数字b") If a > b Then Print "最大数字为" & a & (Chr(13) & Chr(10)) & "最小数字为" & b Else Print "最大数字为" & b & (Chr(13) & Chr(10)) & "最小数字为"...

Private Sub Command1_Click() n = CInt(InputBox("求N!,请输入N的值:")) s = 1 For i = 2 To n s = s * i Next i MsgBox ("N!=" & s) End Sub

窗体上画一个按钮 Private Sub Command1_Click() a = InputBox("请输入A") b = InputBox("请输入B") Me.Print a, b c = a a = b b = c Me.Print a; b End Sub

Dim MyValue MyValue = Int(Rnd*10^N) if MyValue < 10^(N-1) then MyValue = MyValue + (Int(Rnd*9)+1) * 10^(N-1) end if 没认证是否正确,思路是产生一个N位的随机数,不满N位在最高位再补一个一位随机数

Private Sub Form_Click()Dim n As Integer, a() As Integer, i As Integer, j As Integern = Val(InputBox("请输入行数"))ReDim a(1 To n, 1 To n)For i = 1 To n For j = 1 To i If j = 1 Or j = i Then a(i, j) = 1 Else a(i, j) = a(i - 1, ...

一、InputBox函数 1、作用 显示一个输入框,并提示用户在文本框中输入文本、数字或选中某个单元格区域,当按下确定按钮后返回包含文本框内容的字 符串。 2、语法 InputBox(Prompt[,Title][,Default][,Xpos][,Ypos][,Helpfile,Context]) 参数说明...

Public Class Form1 Private Function jc1(ByVal q) Dim i%, p% p = 1 For i = 1 To q Step 1 p = p * i Next Return p End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1....

网站首页 | 网站地图
All rights reserved Powered by www.knrt.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com