Notices

Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Visual Basic Help

Post Reply New Thread Subscribe Search this Thread
 
 
Thread Tools
Old 10-18-08, 06:20 AM Thread Starter   #1
lil layzie
Registered

 
lil layzie's Avatar 

Join Date: Aug 2004

 
Visual Basic Help


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.



Quote:
-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 :



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.

__________________
A64 3400+ 1MB CH/CG | DFI Lanparty UT nF3 250GB | 1Gb (2x512MB) PC3500 OCZ EB
EVGA GeForce 7800GS 256MB AGP | Creative SB Audigy2 ZS Platinum
WD 74Gb Raptor | Maxtor 120Gb DiamondMax 9 | Sony CRX100E CD-RW
OCZ Powerstream 520w PSU | Chieftec Black Dragon
5x80m ThermalTake Thunderblades | 1x92m Zalman Quiet Fan
Samsung SyncMaster 171v | Logitech Z-680 | Sennheiser PC 150
Logitech Internet Navigator Keyboard & Blue MX510 Mouse

:beer:

Last edited by lil layzie; 10-18-08 at 08:49 AM.
lil layzie is offline   QUOTE Thanks
Old 10-18-08, 07:52 AM   #2
seadave77

 
seadave77's Avatar 

Join Date: Jul 2002
Location: Newnan, GA

 
After "Call EmptyWarning()" and "Call CCWarning()" put "Exit Sub"
seadave77 is offline   QUOTE Thanks
Old 10-18-08, 08:04 AM Thread Starter   #3
lil layzie
Registered

 
lil layzie's Avatar 

Join Date: Aug 2004

 
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.



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

__________________
A64 3400+ 1MB CH/CG | DFI Lanparty UT nF3 250GB | 1Gb (2x512MB) PC3500 OCZ EB
EVGA GeForce 7800GS 256MB AGP | Creative SB Audigy2 ZS Platinum
WD 74Gb Raptor | Maxtor 120Gb DiamondMax 9 | Sony CRX100E CD-RW
OCZ Powerstream 520w PSU | Chieftec Black Dragon
5x80m ThermalTake Thunderblades | 1x92m Zalman Quiet Fan
Samsung SyncMaster 171v | Logitech Z-680 | Sennheiser PC 150
Logitech Internet Navigator Keyboard & Blue MX510 Mouse

:beer:

Last edited by lil layzie; 10-18-08 at 08:50 AM.
lil layzie is offline   QUOTE Thanks
Old 10-18-08, 03:56 PM   #4
AtomicMonkey
Member



Join Date: May 2006
Location: CT

 
The quick and dirty way would be
Code:
OrderForm = OrderForm & "Total Price: " + totalLabel.Text

__________________

Gigabyte G1.Sniper 3 : i7 3770K : G.Skill Ripjaw X 16GB : Gigabyte GTX680 OC + eVGA 7800GT : Intel 520 180GB : Corsair HX750
Windows 7 x64
AtomicMonkey is offline   QUOTE Thanks
Old 10-19-08, 07:52 AM Thread Starter   #5
lil layzie
Registered

 
lil layzie's Avatar 

Join Date: Aug 2004

 
quick and dirty eh lol.

thanks for help.

much appreciated

__________________
A64 3400+ 1MB CH/CG | DFI Lanparty UT nF3 250GB | 1Gb (2x512MB) PC3500 OCZ EB
EVGA GeForce 7800GS 256MB AGP | Creative SB Audigy2 ZS Platinum
WD 74Gb Raptor | Maxtor 120Gb DiamondMax 9 | Sony CRX100E CD-RW
OCZ Powerstream 520w PSU | Chieftec Black Dragon
5x80m ThermalTake Thunderblades | 1x92m Zalman Quiet Fan
Samsung SyncMaster 171v | Logitech Z-680 | Sennheiser PC 150
Logitech Internet Navigator Keyboard & Blue MX510 Mouse

:beer:
lil layzie is offline   QUOTE Thanks
Old 10-21-08, 04:40 AM   #6
Sykeo
New Member



Join Date: Oct 2008

 
Quote:
Originally Posted by lil layzie View Post
quick and dirty eh lol.

thanks for help.

much appreciated
Just wanted to add in vb the proper way to check values would to actuall
iterate through all the components and check their values...

This way if you were to change the form dialog to include new items it would also be checked without adding to the code....

http://stackoverflow.com/questions/1...ntainer-object
Sykeo is offline   QUOTE Thanks

Post Reply New Thread Subscribe


Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Mobile Skin
All times are GMT -5. The time now is 05:59 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
You can add these icons by updating your profile information to include your Heatware ID, Benching Profile ID or your Folding/SETI profile ID. Edit your profile!
X

Welcome to Overclockers.com

Create your username to jump into the discussion!

New members like you have made this the best community on the Internet since 1998!


(4 digit year)

Why Join Us?

  • Share experience
  • Max out your hardware
  • Best forum members anywhere
  • Customized forum experience

Already a member?