VB2010 combobox on form

Discussion in 'Mixed Languages' started by dawoods, Oct 6, 2012.

  1. dawoods

    dawoods MDL Novice

    Oct 6, 2012
    2
    0
    0
    I have following 2 tables : Emp and Branch in my database


    a) Emp Table Columns
    Emp1DEmpNameBranchID
    0001Tom11
    0002John16
    0003Mary13
    0004Joe10






    b) Branch Table Columns
    BranchIDBranchName
    11Delhi
    12Mumbai
    13Calcutta
    14Bangalore
    15Chennai
    16Pune


    I am using dataset approach for retreiving records


    In my Employee data navigation form, I have a text box each for EmpID and EmpName and a combobox for


    Branch Name.


    On this navigation form, I am able to display the contents of EmpID and EmpName textboxes. However, I am


    not able to display the associated BranchName tagged to the BranchID.


    How do I correctly display the BranchName for each employee in the navigation form? Please help
     
  2. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    you need to clarify your question are you having trouble finding a way to match the number in the database to the branchid by not knowing how to find the number at the end or is it a literally a problem with displaying the branchname in the form
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. dawoods

    dawoods MDL Novice

    Oct 6, 2012
    2
    0
    0
    On my form, the 2 textboxes should display "0001" and "Tom". In the combobox, the display should be "Delhi".
    When i move the record pointer, the for should display the following
    Textboxes should display "0002" and "John". In the combobox, the display should be "Pune".

    Thnaks for the support
     
  4. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #4 stevemk14ebr, Oct 11, 2012
    Last edited by a moderator: Apr 20, 2017
    don't know if this is what u want but here ya go, make 3 textboxes called textbox 1 2 and 3 on the form
    then paste this code
    Code:
    Public Class Form1
        Dim str As String
        Dim strArr() As String
        Dim count As Integer
        Dim box1, box2, tempbox3, box3 As String
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            str = "0001 Tom 11"
    'splits the string into 3 seperate strings after each space
            strArr = str.Split(" ")
    'putting the string array into variables,no point in using a loop since it's only 3
            box1 = strArr(0)
            box2 = strArr(1)
    'string.replace needs a new variable so a temp box is used
            tempbox3 = strArr(2)
    'replacing the number with the corresponding location
            box3 = tempbox3.Replace("11", "Delhi")
            TextBox1.Text = box1
            TextBox2.Text = box2
            TextBox3.Text = box3
    
    
        End Sub
    End Class
    this is just an example u would probably need some loops if you are using a database this is just for proof of concept
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...