是的,這是一個非常糟糕的問題,可能是任何一個體面的VB.NET程序員都應該知道的問題。那麼,我是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
我的錯誤是類型「的InputBox」沒有定義。我怎樣才能使它被定義?
謝謝,
Odinulf
不知道從何處取得這個詞的InputBox?看看頂部的課程,你稱之爲「Form2」。這有幫助嗎? – Smudge202