?
Solved

Visual basic.net problem

Posted on 2005-03-04
5
Medium Priority
?
295 Views
Last Modified: 2013-12-04
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

0
Comment
Question by:fishmanfishman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:kneH
ID: 13459271
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...
0
 

Author Comment

by:fishmanfishman
ID: 13459509
im not sure how to
0
 
LVL 12

Accepted Solution

by:
kneH earned 1000 total points
ID: 13459561
It's been a while for me... but here's the general idear.

Store the option the user chooses in a variable.

dim sumtin as integer

sumtin = MSGBOX(yesnocancel, .... etc)

(the autocomplete should show that)
Also yes, no and cancel all give a diff output
1, 0 and 3 or something... help will tell ya

then create the if

if sumtin = 0 then
MSGBOX(NO, .....)
elseif sumtin=1 then
MSGBOX(yes,......)

etc etc

get it?
0
 

Author Comment

by:fishmanfishman
ID: 13472684
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
0
 
LVL 12

Expert Comment

by:kneH
ID: 13705673
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.
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This is about my first experience with programming Arduino.
Progress
Starting up a Project
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question