sub text1_click() form_Keys.show text1.text="" end subdim KeyStrings as stringsub form_keys_onload() Keystrings="" end sub sub form_keys_Command(index) Keystrings=Keystrings & Command(index).Caption text1.text=Keystings end subsub form_keys_CommandEnd() me.hide end subform_keys为窗体,上面有命令按钮控件数组。
Public InputVal As String 主画面中写代码如下 Private Sub Text1_Click() FrmKey1.Show Text1.Text = InputVal End Sub在FrmKey1中写代码如下 Private Sub Cmd_Enter_Click() InputVal = Text1.Text Unload Me End SubPrivate Sub Command1_Click(Index As Integer) If Index <> 10 Then Text1.Text = Text1.Text & Index End If
End Sub 为什么在关闭了FrmKey1窗口后,主窗口中Text1.Text值不能更新为新值?望指教!
'在窗体添加一个数组控件,作为输入键盘。 Private Sub Command1_Click(Index As Integer) '在按钮数组上单击时触发事件 Text1 = Text1 & Command1(Index).Caption End SubPrivate Sub Command2_Click() '清空文本框 Text1 = "" End SubPrivate Sub Command3_Click() '确认完成输入 For i = Command1.LBound To Command1.UBound '起始值为数组控件的下边界,终值为数组控件的上边界 Command1(i).Caption = i Command1(i).Visible = False '按钮数组不可见 Next Command2.Visible = False Command3.Visible = False End SubPrivate Sub Form_Activate() Text1 = "" For i = Command1.LBound To Command1.UBound '起始值为数组控件的下边界,终值为数组控件的上边界 Command1(i).Caption = i Command1(i).Visible = False '按钮数组不可见 Next Command2.Visible = False Command3.Visible = False End SubPrivate Sub Text1_Click() For i = Command1.LBound To Command1.UBound Command1(i).Visible = True '按钮数组可见 Next Command2.Visible = True Command3.Visible = True End Sub
Private Sub Text1_Click() FrmKey1.Show End Sub 在FrmKey1中写代码如下 Private Sub Cmd_Enter_Click() frmMain.Text1 = Text1.Text Unload Me End Sub
或者这样:主画面中写代码如下 Private Sub Text1_Click() FrmKey1.Show vbModal, me Text1.Text = InputVal End Sub使得第二个语句在 FrmKey1 关闭后才执行。
http://www.mndsoft.com/blog/article.asp?id=337
form_Keys.show
text1.text=""
end subdim KeyStrings as stringsub form_keys_onload()
Keystrings=""
end sub
sub form_keys_Command(index)
Keystrings=Keystrings & Command(index).Caption
text1.text=Keystings
end subsub form_keys_CommandEnd()
me.hide
end subform_keys为窗体,上面有命令按钮控件数组。
主画面中写代码如下
Private Sub Text1_Click()
FrmKey1.Show
Text1.Text = InputVal
End Sub在FrmKey1中写代码如下
Private Sub Cmd_Enter_Click()
InputVal = Text1.Text
Unload Me
End SubPrivate Sub Command1_Click(Index As Integer)
If Index <> 10 Then
Text1.Text = Text1.Text & Index
End If
End SubPrivate Sub Form_Load()
Text1.Text = ""
Command1(0).Caption = "0"
Command1(1).Caption = "1"
Command1(2).Caption = "2"
Command1(3).Caption = "3"
Command1(4).Caption = "4"
Command1(5).Caption = "5"
Command1(6).Caption = "6"
Command1(7).Caption = "7"
Command1(8).Caption = "8"
Command1(9).Caption = "9"
End Sub
为什么在关闭了FrmKey1窗口后,主窗口中Text1.Text值不能更新为新值?望指教!
Private Sub Command1_Click(Index As Integer) '在按钮数组上单击时触发事件
Text1 = Text1 & Command1(Index).Caption
End SubPrivate Sub Command2_Click() '清空文本框
Text1 = ""
End SubPrivate Sub Command3_Click() '确认完成输入
For i = Command1.LBound To Command1.UBound '起始值为数组控件的下边界,终值为数组控件的上边界
Command1(i).Caption = i
Command1(i).Visible = False '按钮数组不可见
Next
Command2.Visible = False
Command3.Visible = False
End SubPrivate Sub Form_Activate()
Text1 = ""
For i = Command1.LBound To Command1.UBound '起始值为数组控件的下边界,终值为数组控件的上边界
Command1(i).Caption = i
Command1(i).Visible = False '按钮数组不可见
Next
Command2.Visible = False
Command3.Visible = False
End SubPrivate Sub Text1_Click()
For i = Command1.LBound To Command1.UBound
Command1(i).Visible = True '按钮数组可见
Next
Command2.Visible = True
Command3.Visible = True
End Sub
FrmKey1.Show
End Sub 在FrmKey1中写代码如下
Private Sub Cmd_Enter_Click()
frmMain.Text1 = Text1.Text
Unload Me
End Sub
Private Sub Text1_Click()
FrmKey1.Show vbModal, me
Text1.Text = InputVal
End Sub使得第二个语句在 FrmKey1 关闭后才执行。