vb 添加一个文本框,Name属性设置为Tex1
发布网友
发布时间:2022-05-07 18:15
我来回答
共1个回答
热心网友
时间:2022-07-01 00:18
Private Sub Cmd1_Click()
Dim a() As Integer, n As Integer
Dim minNum As Integer, maxNum As Integer
Dim i As Integer
minNum = 100
maxNum = 200
n = Val(Tex1)
If Not GetRndNum(a(), 1, n, minNum, maxNum) Then Exit Sub
Me.Cls
Print "产生" & CStr(n) & "个100—200之间的随机数"
For i = 1 To n
Print CStr(a(i)); " ";
If i Mod 5 = 0 Then Print
Next i
If Not Paixu(a(), 1, n, False) Then Exit Sub
Print
Print "排序:"
For i = 1 To n
Print CStr(a(i)); " ";
If i Mod 5 = 0 Then Print
Next i
Tex1.SetFocus
End Sub
'随机数
Private Function GetRndNum(a() As Integer, L As Integer, U As Integer, minNum As Integer, maxNum As Integer) As Boolean
On Error GoTo ErrGRN
Dim i As Integer, diata As Integer
ReDim a(L To U)
diata = maxNum - minNum + 1
Randomize
For i = L To U
a(i) = Int(Rnd * diata + minNum)
Next i
GetRndNum = True
ErrGRN:
End Function
'排序
'当p=True时从小到大,p=False时从大到小
Private Function Paixu(a() As Integer, L As Integer, U As Integer, p As Boolean) As Boolean
On Error GoTo ErrPx
Dim i As Integer, j As Integer, k As Integer
Dim T As Integer
For i = L To U - 1
k = i
For j = i + 1 To U
If a(k) < a(j) Xor p Then k = j
Next j
If k <> i Then
T = a(i): a(i) = a(k): a(k) = T
End If
Next i
Paixu = True
ErrPx:
End Function
VB 文本框一输入文字自动复制到文本框二
tex1还是text1?如果是tex1的话那么代码:Private Sub Tex1_Change()Tex2.Text = Tex1.Text End Sub
...和一个文本框(名为Text1),并在命令按钮中编写如下事件代码:
str$(m)=" 2.17" ,共5个字符,前面有个符号位,因为是正数,所以显示空格 space(5)=5个空格 len(str$(m)+space(5))=10
在vb中,如何编程能使文本框中实时显示滚动条的位置
Private Sub HScroll1_Change() Text1.Text = Str(HScroll1.Value)End Sub
vb程序 为什么按一个健在文本框中出现三个字符,例如按字符a text1中...
Text1.teXT=string(2,keyascii)这里是两个字符,然后keypress事件本身产生的一个字符,加起来就是三个字符。如果想只显示两个字符,可以在end sub前插入一行:keyascii=0
VB 中的tex1.FontSize 10有什么作用
Text1 中的字体大小为 10 号 ,FontSize 是字体大小 的意思
在vb.net中如何申明一个全局变量并赋值
Public m as string = textbox1.tex 不要放在任何过程里。加在下边 在这里 sub a()可以访问m了。end sub
vb中combo的问题
自己造一个text1文本框,和一个初始visual为false的list 在text1的change事件里写 for i=0 to list.listcount-1 if list.list(i)=text1.text then exit sub next list.additem text1.text 在text1的click事件里写 list.top=text1.top+tex1.height list.left=text1.left list.visual=true l...
VB编程:在Texe1中输入一个值,如果TreeView中有这个值就让它加亮显示出来...
End If Next End Sub Private Sub Form_Load()'添加 Node 对象。Dim nodX As Node '声明 Node 变量。Set nodX = TreeView1.Nodes.Add(, , "R", "根节点")'下一个节点是节点 1 ("根节点") 的子节点。Set nodX = TreeView1.Nodes.Add("R", tvwChild, "A", "A节点")下一个...
vb 自定义数据做成绩的录入和查询,这个要怎么实现。
StuData(StuCount-1 ).Name =Text2.Text '姓名文本框 StuData(StuCount-1 ).Score =Text3.Text '成绩文本框 List1.AddItem Text1.Text & “ ” & Text2.Text & “ ” & Text3.Text '每个数据之间隔三个空格 End Sub Ptivate sub Command2_Click() '查询按钮 '这里要说明...
vb6.0多个文本框按照要求合并成一个txt文档
Private Sub Command1_Click()Dim AA AA = Split(Text3, Chr(13))If UBound(AA) > 0 Then For i = 0 To UBound(AA)Text4 = Text4 & Text1 & AA(i) & Text2 & vbCrLf Next End If End Sub 加了一个文本框text4用来保存运行结果。