• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Visual Basic Help

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

lil layzie

Registered
Joined
Aug 30, 2004
This semester I'm taking an Intro To Visual Basic course and we have to use Microsoft Visual Studio 2005 to do all of our work.

I'm currently working on a project and I've done most of the coding but I'm kinda stuck at some parts. I was wondering if any one would like to help me. I would ask my professor but it's the weekend and I don't meet up with that class until Tuesday and he never responds to any emails.

Let me post my GUI and part of the code from my project.

project.jpg


-deleted because it was making thread too long

Okay, I hope I can explain this as clearly as I can. I'm trying to code my Order Button to make it generate a message box confirming my order and listing the cpu type with the price and listing any optional hardware if the user decides to check them. Something like this :

confirm.jpg


I'm having trouble with the first part of my code. Its suppose to check and make sure that the user has entered all his information and checks which cpu type and payment type. If the user didn't do any of that, it will display an error message telling the user to display all the required fields. (By calling the private subs which I have not posted.) I was wondering how do I make the confirmation box not pop up when it asks the user to fill out all the require fields. (the red part of the code is where I'm having trouble placing it)

And also the second part of my code is the private function of the confirmation message box. I was wondering how do i enter a new line of message in the box after it lists the cpu type. Like the part where it says "with the following options"

I hope I explained everything clearly. all this coding stuff is making my brain hurt.
 
Last edited:
Oh! Wow that was simple. Thanks! It worked.
I'm new to VB so yea, kinda hard for me to understand sometimes.

edit-
now im stuck at another part.

help.jpg


How do I get the total from my form to my message box?

The code for my total is:
Code:
Private Function CalculateTotal() As Decimal

        ' declare varibles
        Const video As Decimal = 50D
        Const harddrive As Decimal = 70D
        Const memory As Decimal = 49D
        Const sound As Decimal = 15D
        Const modem As Decimal = 9.99D
        Dim total As Decimal
        Dim isConverted As Boolean

        isConverted = Decimal.TryParse(totalLabel.Text, total)

        ' determines which cpu option is selected
        If advanceRadioButton.Checked Then
            total = 280D
        ElseIf intermediateRadioButton.Checked Then
            total = 160D
        ElseIf basicRadioButton.Checked Then
            total = 99.5D
        Else
        End If


        ' determines which check boxes (if any) are selected
        If videoCheckBox.Checked Then
            total = total + video
        End If
        If harddriveCheckBox.Checked Then
            total = total + harddrive
        End If
        If memoryCheckBox.Checked Then
            total = total + memory
        End If
        If soundCheckBox.Checked Then
            total = total + sound
        End If
        If modemCheckBox.Checked Then
            total = total + modem
        End If

        ' calculate the total with 6% sales tax
        total = total * 0.06D + total

        ' displays the total
        totalLabel.Text = total.ToString("C2")

    End Function

And the code for my message box is:
Code:
Private Function getOrderForm() As String

        Dim OrderForm As String = "You have placed an order for" & vbNewLine

        If advanceRadioButton.Checked = True Then
            OrderForm = OrderForm & "Advance CPU ($280.00)" & vbNewLine
        ElseIf intermediateRadioButton.Checked Then
            OrderForm = OrderForm & "Intermediate CPU ($160.00)" & vbNewLine
        Else : basicRadioButton.Checked = True
            OrderForm = OrderForm & "Basic CPU ($99.50)" & vbNewLine
        End If

        If videoCheckBox.Checked Or _
        harddriveCheckBox.Checked Or _
        memoryCheckBox.Checked Or _
        soundCheckBox.Checked Or _
        modemCheckBox.Checked Then
            OrderForm = OrderForm & "with the following options:" & vbNewLine
        Else
        End If

        If videoCheckBox.Checked Then
            OrderForm = OrderForm & "   Video Card" & vbNewLine
        End If

        If harddriveCheckBox.Checked Then
            OrderForm = OrderForm & "   Hard Drive" & vbNewLine
        End If

        If memoryCheckBox.Checked Then
            OrderForm = OrderForm & "   Memory" & vbNewLine
        End If

        If soundCheckBox.Checked Then
            OrderForm = OrderForm & "   Sound Card" & vbNewLine
        End If

        If modemCheckBox.Checked Then
            OrderForm = OrderForm & "   Modem" & vbNewLine
        End If

        OrderForm = OrderForm & "Total price: "

        Return OrderForm
    End Function
 
Last edited:
Back