【发布时间】:2015-10-13 04:07:51
【问题描述】:
所以我有一个关于我构建的程序的问题。首先,我的教科书不是一个好的资源。其次,我已经完成了一切,“我认为”,除了让总成本流入正确的标签。所以基本上我有两个表格,第一个有我的信息,第二个是你选择你想参加会议的地方。当我运行它时,一切正常,除了总数没有从选项表单交叉到主表单。我已经黔驴技穷了。有什么建议么?
主窗体代码:
Public Class MainForm
Private Sub selectButton_Click(sender As Object, e As EventArgs) Handles selectButton.Click
' Create an instance of the Conference options form
Dim frmOptions As New Conference_Options
' Display the form
frmOptions.ShowDialog()
End Sub
Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
' Close the form
Me.Close()
End Sub
Private Sub resetButton_Click(sender As Object, e As EventArgs) Handles resetButton.Click
' Clear everything
nameTextBox.Clear()
companyTextBox.Clear()
addressTextBox.Clear()
cityTextBox.Clear()
stateTextBox.Clear()
zipTextBox.Clear()
phoneTextBox.Clear()
emailTextBox.Clear()
totalLabel.Text = ""
End Sub
End Class
选项表单代码:
Public Class Conference_Options
Function TotalCost(ByRef dblTotalCost)
Dim dblRegistration As Double
Dim dblDinnerandReg As Double
Dim dblPreCon As Double
'conference registration
If registrationCheckBox.Checked = True Then
dblRegistration = 895
Else
dblRegistration = 0
End If
'dinner and keynote speech
If dinnerCheckBox.Checked = True Then
dblDinnerandReg = 30
Else
dblDinnerandReg = 0
End If
'optional preconference workshop
If preconferenceListBox.SelectedIndex = 0 Then
dblPreCon = 295
ElseIf preconferenceListBox.SelectedIndex = 1 Then
dblPreCon = 295
ElseIf preconferenceListBox.SelectedIndex = 2 Then
dblPreCon = 395
ElseIf preconferenceListBox.SelectedIndex = 3 Then
dblPreCon = 395
ElseIf preconferenceListBox.SelectedIndex = -1 Then
dblPreCon = 0
End If
dblTotalCost = dblRegistration + dblDinnerandReg + dblPreCon
Return dblTotalCost
End Function
Private Sub closeButton_Click(sender As Object, e As EventArgs) Handles closeButton.Click
' Close the form
Me.Close()
End Sub
Private Function totalLabel() As Object
Throw New NotImplementedException
End Function
End Class
我希望你看到我确实付出了很多努力,但我正在努力让它发挥作用。
【问题讨论】:
-
您是否尝试在选项表单中将 TotalCost 公开为公共属性(从函数中设置其值)并像这样调用它:
frmOptions.TotalCost,因为您已经在 Main 表单中保存了它的实例?
标签: vb.net winforms visual-studio