dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: dealing with cumbo box and textbox

  1. #1
    Join Date
    Nov 2006
    Posts
    13

    combobox and textbox

    hi, i'm deena

    i'm working with VB 6.0. I have a combo box. when i select an item from the combo box, i want the system that i'm developing, to generate automatically an output in a textbox, with respect to the current item that i have selected in the combo box. The next time that I select another item from the combo box, the system should generate another output into the textbox, with respect to the new item that i have selected. The name of my cumbo box is 'cboStaffName' and the name of my textbox is 'txtStaffName'.
    I was thinking about using the 'Select Case'. what is the piece of code to relate the item chosen in the cumbo box so as to display an output in the textbox. Where should i include the code? i have been using 'list' for the cumbo box.

    thanks

  2. #2
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    No need to any select cases it's simple :

    In the combobox click event [cboStaffName_Click] put this :

    Code:
    txtStaffName = cboStaffName.List(cboStaffName.ListIndex)
    To have more effcient code put it again in the event "GotFocus"

    .listindex gives you the index of the selected item so you assign to the text the
    .list(index_of_the_selected_item)
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  3. #3
    Join Date
    Nov 2006
    Posts
    13

    dealing with cumbo box and textbox

    hi,
    i'm deena

    I'm using VB 6.0. Infact, what i want is that when i select a name in my cumbo box, the software should automatically generate what is the type of staff the person i selected in the cumbo box is and display it in a textbox. For example, if i select 'Tom' in the cumbo box, then 'engineer' should be displayed in the textbox. Another time when i select 'Jane' in the cumbo box, then 'secretary' should be displayed in my textbox. The name of my cumbo box is 'cboStaffName' and the name of my textbox is 'txtStaffType'. i'm thinking about using the 'ListIndex' from the cumbo box and the 'select case' statement' . Can you please, provide me with the exact code. Where should i placed the code? I don't want to use a database because i do not have much information to processed.

    Thanks

  4. #4
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Sol 1:
    Make another combobox that contains their jobs successivley and when you select an item from the first combo box [click event] display in the textbox the same index of the selected item from the second combo box .

    Sol 2:
    Select case isn't very good idea but if u wanna use it it sould be like this :

    Code:
    Select case combobox.listindex
    case 1
    textbox = "job1"
    case 2
    textbox = "job2"
    .
    .
    .
    end select
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  5. #5
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Ok, it's comboBox not cumboBox. Also it would depend on where the other information is stored. If it is in a database the you will need to open a connection to the database and then open a recordset for the user table that returns the additional info based on the criteria where user = selected user. Then from the recordset you can get the data from the staff field and set the textBox to that value. Make sure to close the recoredset and connection; as well as setting the object variables to Nothing when the form is closed.

Similar Threads

  1. List Box vs TextBox properties in Access reports
    By arturo63 in forum VB Classic
    Replies: 0
    Last Post: 08-07-2006, 11:19 AM
  2. Combo box changing textbox
    By InsuranceGuru in forum VB Classic
    Replies: 2
    Last Post: 06-23-2005, 10:58 PM
  3. Read .cfg file to TextBox and Combo Box
    By hackerx4 in forum VB Classic
    Replies: 0
    Last Post: 03-22-2005, 06:42 PM
  4. Replies: 0
    Last Post: 08-28-2003, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center