自分の入力ボックスを試すことができます
入力フォーム
Public Class frmInputbox
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
btnResponse.Text = MsgBoxResult.Ok
Me.Hide()
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
btnResponse.Text = MsgBoxResult.Cancel
Me.Hide()
End Sub
End Class
ラッパー
Public Class DrZedInputbox
Private Shared _UserResponseDlg As New frmInputbox()
Public Shared Function Inputbox(Prompt As String, Title As String, ByRef TextData As String, Left As Integer, Top As Integer, Icon As System.Drawing.Icon) As MsgBoxResult
Inputbox = MsgBoxResult.Cancel
_UserResponseDlg.Text = Title
_UserResponseDlg.Label1.Text = Prompt
_UserResponseDlg.TextBox1.Text = textData
_UserResponseDlg.Left = Left
_UserResponseDlg.Top = Top
_UserResponseDlg.Icon = Icon
_UserResponseDlg.ShowDialog()
Inputbox = _UserResponseDlg.btnResponse.Text
End Function
Public Shared ReadOnly Property TextData As String
Get
Return _UserResponseDlg.TextBox1.Text
End Get
End Property
Public Shared ReadOnly Property Response As MsgBoxResult
Get
Return CType(_UserResponseDlg.btnResponse.Text, MsgBoxResult)
End Get
End Property
Public Sub Dispose()
_UserResponseDlg = Nothing
End Sub
Protected Overrides Sub Finalize()
_UserResponseDlg = Nothing
MyBase.Finalize()
End Sub
End Class
実装
入力ボックスを表示するには
DrZedInputbox.Inputbox("prompt", "title", "default", 100, 100, Me.Icon)
結果を収集するには (メッセージボックスを使用して表示)
MsgBox("Text data entered: " & DrZedInputbox.TextData)
MsgBox("User response: " & DrZedInputbox.Response)
入力ボックスの処理が終わったら (片付け)
DrZedInputbox.Dispose()
アップデート
写真追加