Link to home
Start Free TrialLog in
Avatar of fishmanfishman
fishmanfishman

asked on

Visual basic.net problem

I am helping a friend build a program using visual basic.net and need help with a combox issue

The problem is when i select a certain option from the combo box i want some of the other options in the combo boxes to disapear. I have used two arrays one of them using bollen algebra. Any help or direction would be helpful. The code for the program is displayed below.

Thanks.

Option Explicit On

Public Class frmPubeckCameras
    Inherits System.Windows.Forms.Form


    Dim straCamera_type As String
    Dim straLens_Name As String
    Dim straStorage_medium As String
    Dim straFilm_type As String

    Dim straProducts(16, 5) As String
    Dim blnaCompatibility(16, 2) As Boolean
    Dim sngTotalPrice As Single

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim intIndex As Integer

        sngTotalPrice = 0
        straProducts(0, 0) = "FB01S"            ' Code
        straProducts(0, 1) = "FB01S Studio"     ' Name
        straProducts(0, 2) = "A detachable tripod mounted camera specially designed for highly lit studio shoots" ' Description
        straProducts(0, 3) = "150"              ' Price
        straProducts(0, 4) = "1"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(1, 0) = "FB02DS"           ' Code
        straProducts(1, 1) = "FB02DS Digital"         ' Name
        straProducts(1, 2) = "An ultra high resolution digital camera suitable for studio or location shoots designed for maximum flexibility. It is sold with it’s ownprofessional digital editing package" ' Description"
        straProducts(1, 3) = "210"              ' Price
        straProducts(1, 4) = "1"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(2, 0) = "FB035X"           ' Code
        straProducts(2, 1) = "FB035X"         ' Name
        straProducts(2, 2) = "A robust ultra light, impact resistant and temperature tolerant 35mm SLR. This is a new model specially designed for photography in more extremeconditions" ' Description
        straProducts(2, 3) = "189"              ' Price
        straProducts(2, 4) = "1"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(3, 0) = "SB100"            ' Code
        straProducts(3, 1) = "Sherbourne 1"     ' Name
        straProducts(3, 2) = "About Lens 1"     ' Description
        straProducts(3, 3) = "30"               ' Price
        straProducts(3, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(4, 0) = "SB200"            ' Code
        straProducts(4, 1) = "Sherbourne 2"     ' Name
        straProducts(4, 2) = "About Lens 2"     ' Description
        straProducts(4, 3) = "35"               ' Price
        straProducts(4, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(5, 0) = "CB100"            ' Code
        straProducts(5, 1) = "Cranbourne 1"     ' Name
        straProducts(5, 2) = "About Lens 3"     ' Description
        straProducts(5, 3) = "40"               ' Price
        straProducts(5, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(6, 0) = "CB200"     ' Code
        straProducts(6, 1) = "Cranbourne 2"           ' Name
        straProducts(6, 2) = "About Lens 4"     ' Description
        straProducts(6, 3) = "50"               ' Price
        straProducts(6, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(7, 0) = "CB400"     ' Code
        straProducts(7, 1) = "Cranbourne 3"           ' Name
        straProducts(7, 2) = "About Lens 5"     ' Description
        straProducts(7, 3) = "59"               ' Price
        straProducts(7, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(8, 0) = "RX100"  ' Code
        straProducts(8, 1) = "Regis X range 1"           ' Name
        straProducts(8, 2) = "About Lens 5"     ' Description
        straProducts(8, 3) = "59"               ' Price
        straProducts(8, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(9, 0) = "RX200"  ' Code
        straProducts(9, 1) = "Regis X range 2"           ' Name
        straProducts(9, 2) = "About Lens 5"     ' Description
        straProducts(9, 3) = "59"               ' Price
        straProducts(9, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(10, 0) = "RX400"  ' Code
        straProducts(10, 1) = "Regis X range 3"           ' Name
        straProducts(10, 2) = "About Lens 5"     ' Description
        straProducts(10, 3) = "59"               ' Price
        straProducts(10, 4) = "2"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(11, 0) = "D001"            ' Code
        straProducts(11, 1) = "D512M Card"        ' Name
        straProducts(11, 2) = "About Storage 1"  ' Description
        straProducts(11, 3) = "50"               ' Price
        straProducts(11, 4) = "3"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(12, 0) = "D002"              ' Code
        straProducts(12, 1) = "D1G Card"        ' Name
        straProducts(12, 2) = "About Storage 2"  ' Description
        straProducts(12, 3) = "75"               ' Price
        straProducts(12, 4) = "3"                ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(13, 0) = "D003"           ' Code
        straProducts(13, 1) = "D1.5G Card"       ' Name
        straProducts(13, 2) = "About Storage 3" ' Description
        straProducts(13, 3) = "85"              ' Price
        straProducts(13, 4) = "3"               ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(14, 0) = "ISO100"          ' Code
        straProducts(14, 1) = "Film 1"          ' Name
        straProducts(14, 2) = "About Film 1"    ' Description
        straProducts(14, 3) = "5"               ' Price
        straProducts(14, 4) = "3"               ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(15, 0) = "ISO200"          ' Code
        straProducts(15, 1) = "Film 2"          ' Name
        straProducts(15, 2) = "About Film 2"    ' Description
        straProducts(15, 3) = "10"              ' Price
        straProducts(15, 4) = "3"               ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        straProducts(16, 0) = "ISO400"          ' Code
        straProducts(16, 1) = "Film 3"          ' Name
        straProducts(16, 2) = "About Film 3"    ' Description
        straProducts(16, 3) = "15"              ' Price
        straProducts(16, 4) = "3"               ' Type (1 = Camera, 2 = Lens, 3 = Storage/Film)

        ' FB01S Studio
        blnaCompatibility(0, 0) = True          ' Compatible with itself!
        blnaCompatibility(0, 1) = False
        blnaCompatibility(0, 2) = False

        ' FB02DS Digital
        blnaCompatibility(1, 0) = False
        blnaCompatibility(1, 1) = True          ' Compatible with itself!
        blnaCompatibility(1, 2) = False

        ' FB035X
        blnaCompatibility(2, 0) = False
        blnaCompatibility(2, 1) = False
        blnaCompatibility(2, 2) = True          ' Compatible with itself!

        ' Sherbourne 1
        blnaCompatibility(3, 0) = True          ' Compatible with FB01S
        blnaCompatibility(3, 1) = False
        blnaCompatibility(3, 2) = False

        ' Sherbourne 2
        blnaCompatibility(4, 0) = True          ' Compatible with FB01S
        blnaCompatibility(4, 1) = False
        blnaCompatibility(4, 2) = False

        ' Cranbourne 1
        blnaCompatibility(5, 0) = False
        blnaCompatibility(5, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(5, 2) = True ' Compatible with the FB035X

        ' Cranbourne 2
        blnaCompatibility(6, 0) = False
        blnaCompatibility(6, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(6, 2) = True ' Compatible with the FB035X

        ' Cranbourne 3
        blnaCompatibility(7, 0) = False
        blnaCompatibility(7, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(7, 2) = True ' Compatible with the FB035X

        ' Reqis X Range
        blnaCompatibility(8, 0) = False
        blnaCompatibility(8, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(8, 2) = True ' Compatible with the FB035X

        ' Reqis X Range
        blnaCompatibility(9, 0) = False
        blnaCompatibility(9, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(9, 2) = True ' Compatible with the FB035X

        ' Reqis X Range
        blnaCompatibility(10, 0) = False
        blnaCompatibility(10, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(10, 2) = True ' Compatible with the FB035X

        ' Digital Media
        blnaCompatibility(11, 0) = False
        blnaCompatibility(11, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(11, 2) = False

        ' Digital Media
        blnaCompatibility(12, 0) = False
        blnaCompatibility(12, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(12, 2) = False

        ' Digital Media
        blnaCompatibility(13, 0) = False
        blnaCompatibility(13, 1) = True ' Compatible with the FB02DS
        blnaCompatibility(13, 2) = False

        ' Film
        blnaCompatibility(14, 0) = True ' Compatible with FB01S
        blnaCompatibility(14, 1) = False
        blnaCompatibility(14, 2) = True ' Compatible with the FB035X

        ' Film
        blnaCompatibility(15, 0) = True ' Compatible with FB01S
        blnaCompatibility(15, 1) = False
        blnaCompatibility(15, 2) = True ' Compatible with the FB035X

        ' Film
        blnaCompatibility(16, 0) = True ' Compatible with FB01S
        blnaCompatibility(16, 1) = False
        blnaCompatibility(16, 2) = True ' Compatible with the FB035X

        For intIndex = 0 To 16 'Puts data into combo box                              
            cbxProducts.Items.Add(straProducts(intIndex, 1))
        Next
        For intIndex = 0 To 2
            cbxBodyName.Items.Add(straProducts(intIndex, 1))
        Next
        For intIndex = 3 To 10
            cbxLensName.Items.Add(straProducts(intIndex, 1))
        Next
        For intIndex = 11 To 16
            cbxStorageMedium.Items.Add(straProducts(intIndex, 1))
        Next

        rtbProducts.Text = "CODE: FB01S NAME:   FB01S Studio DESCRIPTION: A detachable tripod mounted camera specially designed for highly lit studio shoots PRICE: £150 Type : Camera"


    End Sub

    Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click
        txttotal.Text = "£" & FormatNumber(sngTotalPrice, 2)
    End Sub

    Private Sub cmdAddProductId_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddProductId.Click
        ' Populate the Products ComboBox

        Dim intQuantity As Integer
        Dim sngPrice As Single

        If txtQuantity.Text <> "" Then
            If IsNumeric(txtQuantity.Text) = True Then
                ' Get Quantity
                intQuantity = CInt(txtQuantity.Text)
                ' Calculate price. Quantity x item price
                sngPrice = intQuantity * CSng(straProducts(cbxProducts.SelectedIndex, 3))
                ' Add sale to till roll
                rtbTillRoll.Text = rtbTillRoll.Text & Chr(10) & CStr(intQuantity) & " x " & straProducts(cbxProducts.SelectedIndex, 1) & " = £" & FormatNumber(sngPrice, 2)
                sngTotalPrice = sngTotalPrice + sngPrice
            End If
        End If
    End Sub

    Private Sub cmdAddProduct_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddProductSd.Click
        ' Populate the Products ComboBox
        Dim sngPrice As Single

        sngPrice = CSng(straProducts(cbxBodyName.SelectedIndex, 3)) ' Add sale to till roll
        'rtbTillRoll.Text = rtbTillRoll.Text & Chr(10) & straProducts(cbxBodyName.SelectedIndex, 1) & " = £" & FormatNumber(sngPrice, 2)

        sngPrice = sngPrice + CSng(straProducts(cbxLensName.SelectedIndex + 3, 3)) ' Add sale to till roll
        'rtbTillRoll.Text = rtbTillRoll.Text & Chr(10) & straProducts(cbxLensName.SelectedIndex + 3, 1) & " = £" & FormatNumber(sngPrice, 2)

        sngPrice = sngPrice + CSng(straProducts(cbxStorageMedium.SelectedIndex + 11, 3)) ' Add sale to till roll
        'rtbTillRoll.Text = rtbTillRoll.Text & Chr(10) & straProducts(cbxStorageMedium.SelectedIndex + 11, 1) & " = £" & FormatNumber(sngPrice, 2)

        sngPrice = sngPrice * 0.8 ' 20% off

        rtbTillRoll.Text = rtbTillRoll.Text & Chr(10) & straProducts(cbxBodyName.SelectedIndex, 1) & ", " & straProducts(cbxLensName.SelectedIndex + 3, 1) & ", " & straProducts(cbxStorageMedium.SelectedIndex + 11, 1) & " = £" & FormatNumber(sngPrice, 2)

        sngTotalPrice = sngTotalPrice + sngPrice

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
        sngTotalPrice = 0 'Clears Variable
        rtbTillRoll.Text = "" 'Clears the Text Box
        txttotal.Text = ""
        txtQuantity.Text = ""
    End Sub

Avatar of kneH
kneH

Can't ya just use an if statements tree?
If msgbox=1 then
   only show the option you want to keep in the msgbox
elseif msgbox=2 then
etc etc...
Avatar of fishmanfishman

ASKER

im not sure how to
ASKER CERTIFIED SOLUTION
Avatar of kneH
kneH

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But i am using a combo box. I am using an array on the sub form load to load the products in and i want to use a bolean array to validate it. Surely what you are saying goes against that. Correct me if i am wrong
Yes it does...

But for all I know it's not possible to put a bolean array in a subform.
Best I can think of is creating a list in the subform as you mentioned and place an "order button" on the main form.

Or put the order button on the subform in front of each product.