是的,这是一个非常糟糕的问题,可能任何半正派的 VB.NET 程序员都应该知道。好吧,我是 VB.NET 的新手,所以我需要一点帮助。
我在另一个窗体类旁边创建了一个 Windows 窗体类,它的代码是这样的:
Imports System.Windows.Forms
Public Class Form2
Protected m_BlankValid As Boolean = True
Protected m_ReturnText As String = ""
Public Overloads Function ShowDialog( _
ByVal TitleText As String, _
ByVal PromptText As String, _
ByVal DefaultText As String, _
ByRef EnteredText As String, _
ByVal BlankValid As Boolean) As System.Windows.Forms.DialogResult
m_BlankValid = BlankValid
Me.PromptLabel.Text = PromptText
Me.Text = TitleText
Me.Txt_TextEntry.Text = DefaultText
Me.ShowDialog()
EnteredText = m_ReturnText
Return Me.DialogResult
End Function
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Me.Txt_TextEntry.Text = "" Then
Me.OK_Btn.Enabled = m_BlankValid
Else
Me.OK_Btn.Enabled = True
End If
End Sub
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.DialogResult = System.Windows.Forms.DialogResult.OK
m_ReturnText = Me.Txt_TextEntry.Text
Me.Close()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
m_ReturnText = ""
Me.Close()
End Sub
End Class
显然,我的设计中有一些图形。
要调用我的课程,我想使用以下代码:
Dim TextReturned As String = ""
Dim a As New InputBox
If a.ShowDialog("The Title", "The Prompt", "Default", TextReturned, False) = Windows.Forms.DialogResult.Cancel Then
' Cancel Pressed
Beep()
Else
'
End If
我的错误是未定义“输入框”类型。我怎样才能使它被定义?
谢谢,
奥迪努尔夫