I'm in the chapter in my Visual Basic book on creating multiple forms, modules, and menus.
The first problem, is to create a problem that calculates a total for going to conference.
it gives MainForm and OptionsForm design. Below is what I recreated
![Name: MainForm..jpg
Views: 72
Size: 33.9 KB]()
![Name: OptionsForm.jpg
Views: 46
Size: 38.2 KB]()
The assignment
The Conference Options form allows the user to select the regular conference registration, the optional opening night dinner, and an optional preconference workshop; user cannot select optional events without selecting registration. When the Close button is clicked, this form should be removed from the screen and the total registration fee should appear on the main form
It also gives a tip about using a global variable to hold the total cost, so both form will have access to the variable
I haven't finished the program and most I can do. I have module setup in addition to the two forms.
this is button on the MainForm to get conference info and total
this is the module
this is the OptionsForm code
What I can't figure out, ConferenceTotal function works on the OptionsForm, but not on the CalculateModule. The I added the 1 to ConferenceTotal so I didn't get some error, and didn't want to delete and retype later. Somehow I have something off when referencing the chkRegistration on the OptionsForm. The outside IfThen statement messagebox pops up when I call CalcuateTotal1 function.
It's possible I'm not fully understand module and what can be used in it. The books says they're meant to contain general purpose procedures, functions, and declarations that are available to all forms in a project. So, maybe I'm not allowed to use radio buttons, checkboxes, lists and so forth in specific forms.
Once I understand this, I can do the rest.
The first problem, is to create a problem that calculates a total for going to conference.
it gives MainForm and OptionsForm design. Below is what I recreated
The assignment
Quote:
The Conference Options form allows the user to select the regular conference registration, the optional opening night dinner, and an optional preconference workshop; user cannot select optional events without selecting registration. When the Close button is clicked, this form should be removed from the screen and the total registration fee should appear on the main form
I haven't finished the program and most I can do. I have module setup in addition to the two forms.
this is button on the MainForm to get conference info and total
Code:
Private Sub btnConferenceOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConferenceOptions.Click
'==================================
'declare variables
'=================================
Dim frmOptionsForm As New frmOptionsForm
frmOptionsForm.ShowDialog()
'==================================
'display total
'=================================
lblTotal.Text = g_decTotalCost.ToString("c")
End Sub
Code:
Module CalucateModule
'==================================
'declare global constants and variables
'==================================
Public Const g_decRegistration As Decimal = 895
Public Const g_decDinner As Decimal = 30
Public Const g_decECommerce As Decimal = 295
Public Const g_decWeb As Decimal = 295
Public Const g_decVisualBasic As Decimal = 395
Public Const g_decNetworkSecurity As Decimal = 395
Public g_decTotalCost As Decimal
Public Function ConferenceTotal1() As Decimal
If frmOptionsForm.chkRegistration.Checked = True Then
g_decTotalCost += g_decRegistration
MessageBox.Show("test if IfThen statement")
End If
MessageBox.Show("test outside IfThen statement")
Return g_decTotalCost
End Function
End Module
Code:
Public Class frmOptionsForm
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Call ConferenceTotal()
Me.Close()
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
chkDinner.Checked = False
chkRegistration.Checked = False
lstOptions.SelectedIndex = -1
End Sub
Public Function ConferenceTotal() As Decimal
If chkRegistration.Checked = True Then
g_decTotalCost += g_decRegistration
End If
Return g_decTotalCost
End Function
End Class
It's possible I'm not fully understand module and what can be used in it. The books says they're meant to contain general purpose procedures, functions, and declarations that are available to all forms in a project. So, maybe I'm not allowed to use radio buttons, checkboxes, lists and so forth in specific forms.
Once I understand this, I can do the rest.