Creating User Control

tghealdstudent

New member
Joined
Mar 20, 2007
Messages
2
Programming Experience
Beginner
Ok, I'm new here, but I have a graduation project due, I pretty much completed the baseline code 6 months ago, but the Dean would like to see a more "flashy" appeal. What I need to do is create a user control, with 3 buttons, when the buttons are clicked the user control will disappear and a new form will appear, each button has a separate form, then the code for each form will be run.

Splash (User Control)
---btnselect2x2 - when selected hides and opens form1
---btnselect3x3 - when selected hides and opens form2
---btnselect4x4 - when selected hides and opens form3
----form1 = btnselect2x2 - when closed opens Splash
----form2 = btnselect3x3 - when closed opens Splash
----form3 = btnselect4x4 - when closed opens Splash

This is the basic outline.

Any input would be greatly appreciated, I would like a GUI explanation as I no nothing about straight coding.

Thanks in advance,

TG
 
This is the code I have for Form1, clicking on btnSelect2x2 opens Form2.vb
VB.NET:
Expand Collapse Copy
    Dim F2 As New Form2
    'Dim F3 As New Form3
    'Dim F4 As New Form4

    Private Sub btnSelect2x2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect2x2.Click
        F2.Show()
        Me.Hide()
    End Sub

    Private Sub btnSelect3x3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect3x3.Click
        'F3.Show()
    End Sub

    Private Sub btnSelect4x4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect4x4.Click
        'F4.Show()
    End Sub
End Class
This is the code for Form2.vb, but when I run I get an exception on Form1.vb "F2.show() is highlighted in yellow"

Here is the error: "Resources 'Form2.resx' and 'Form2x2.resx' have the same manifest resource name 'CramersCalc.Form2.resources'." I Fixed this error, but the code below will not run, something about not being able to run in single thread.

VB.NET:
Expand Collapse Copy
Dim sngValA1 As Single 'Declaration for txtValA1~D4
    Dim sngValA2 As Single '    "   "
    Dim sngValB1 As Single '    "   "
    Dim sngValB2 As Single '    "   "
    Dim sngAnsOne As Single '   "   "   
    Dim sngAnsTwo As Single '   "   "
    Dim sngDeterminent2x2 As Single 'Determinent Value for a 2 x 2 Matrix
    Dim sngDeterminentDA2x2 As Single 'Determinent Value for A on 2x2 Matrix
    Dim sngDeterminentDB2x2 As Single 'Determinent Value for B on 2x2 Matrix
    Dim sngSolutionA2x2 As Single 'Solution for A on 2x2 Matrix
    Dim sngSolutionB2x2 As Single 'Solution for B on 2x2 Matrix
    'Getting users input for the equations trying to solve
    Private Sub txtVarAOne_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarAOne.TextChanged
        sngValA1 = Val(txtVarAOne.Text)
    End Sub
    'Getting users input for the equations trying to solve
    Private Sub txtVarATwo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarATwo.TextChanged
        sngValA2 = Val(txtVarATwo.Text)
    End Sub
    'Getting users input for the equations trying to solve
    Private Sub txtVarBOne_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarBOne.TextChanged
        sngValB1 = Val(txtVarBOne.Text)
    End Sub
    'Getting users input for the equations trying to solve
    Private Sub txtVarBTwo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarBTwo.TextChanged
        sngValB2 = Val(txtVarBTwo.Text)
    End Sub
    'Getting users input for the equations trying to solve
    Private Sub txtAnsOne_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAnsOne.TextChanged
        sngAnsOne = Val(txtAnsOne.Text)
    End Sub
    'Getting users input for the equations trying to solve
    Private Sub txtAnsTwo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAnsTwo.TextChanged
        sngAnsTwo = Val(txtAnsTwo.Text)
    End Sub
    Private Sub btnSolveEquation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSolveEquation.Click
        'Processing the user's input for a 2x2 Matrix Equation and determining the Determinents
        sngDeterminent2x2 = (sngValA1 * sngValB2) - (sngValA2 * sngValB1)
        sngDeterminentDA2x2 = (sngAnsOne * sngValB2) - (sngAnsTwo * sngValB1)
        sngDeterminentDB2x2 = (sngValA1 * sngAnsTwo) - (sngValA2 * sngAnsOne)

        'Determining the Solutions for A & B
        sngSolutionA2x2 = sngDeterminentDA2x2 / sngDeterminent2x2
        sngSolutionB2x2 = sngDeterminentDB2x2 / sngDeterminent2x2

        'Displaying the solutions in A & B
        lblVarA.Text = sngSolutionA2x2
        lblVarB.Text = sngSolutionB2x2

        'Displaying the Determinent Value
        lblDeterminent.Text = sngDeterminent2x2

        'If determinent is equal to zero then there is no solution for an equation
        If sngDeterminent2x2 = 0 Then
            txtVarAOne.Text = ""
            txtVarATwo.Text = ""
            txtVarBOne.Text = ""
            txtVarBTwo.Text = ""
            txtAnsOne.Text = ""
            txtAnsTwo.Text = ""
            lblVarA.Text = ""
            lblVarB.Text = ""
            lblErrorDisp1.Text = "Determinent = 0 ~ No Solution"
        End If
    End Sub
    Private Sub btnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearAll.Click
        'Clears all fields when clicked
        txtVarAOne.Text = "0"
        txtVarATwo.Text = "0"
        txtVarBOne.Text = "0"
        txtVarBTwo.Text = "0"
        txtAnsOne.Text = "0"
        txtAnsTwo.Text = "0"
        lblVarA.Text = ""
        lblVarB.Text = ""
        lblErrorDisp1.Text = ""
        lblDeterminent.Text = ""

    End Sub
End Class
 
Last edited:
Back
Top