VB题目:单击按钮1时,将其对应的数字字符添加到text1的尾部

2025-03-26 09:28:15
推荐回答(3个)
回答1:

将按钮的commandbutton.Caption 定义为该按钮对应的数字。用按钮 "1" 来举例
sub commandButton1_click()
text1=text1& commandButton1.caption
end sub
'------------------------------------
批量定义按钮的Caption
sub ReDimCaption()
dim n as integer
for n= 1 to n '-----n为按钮数量
userform1.controls.item("CommandButton" & n).caption=n
next x
end sub

回答2:

Private Sub Command1_Click()
n = InputBox("请输入一个数字")
Text1 = Text1 & n
End Sub

回答3:

text1.text=text1.text & command1.caption