PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
vb.net split text in a combobox item to multiple items-VBForums
Results 1 to 14 of 14

Thread: vb.net split text in a combobox item to multiple items

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2015
    Posts
    17

    vb.net split text in a combobox item to multiple items

    A drug index software
    simply every combobox is filled from a field in the database like this:

    Name:  136488940.jpg
Views: 243
Size:  23.8 KB

    but as marked with red arrow in field Routes when i choose dose 20
    the opposite value (B&B) is listed in combobox named (Route) like this:

    Name:  262244685.jpg
Views: 234
Size:  6.8 KB

    i want it to be split in separate items by the separator (&) to be viewed like this:

    Name:  840516181.jpg
Views: 227
Size:  6.5 KB

    this is my code:
    Code:
      Dim cnn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Medication.accdb")
       Dim da As OleDbDataAdapter
       Dim cm As OleDbCommandBuilder
       Dim cmd As OleDbCommand
       Dim itemRoute As String()
       Private Sub MedType1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles MedType1.SelectedIndexChanged
    
           MedName1.Items.Clear()
           MedDose1.Items.Clear()
           MedRoute1.Items.Clear()
    
           If MedType1.SelectedItem = ("Antibiotics") Then
    
               Dim dt1 As New DataTable
               dt1.Clear()
               Dim sql As String = "SELECT * FROM Antibiotics"
               da = New OleDbDataAdapter(sql, cnn)
               cm = New OleDbCommandBuilder(da)
               da.Fill(dt1)
    
               For ii As Integer = 0 To dt1.Rows.Count - 1
                   MedName1.Items.Add(dt1(ii)(0))
               Next
    
           End If
    
       End Sub
    
       Private Sub MedName1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles MedName1.SelectedIndexChanged
    
           MedDose1.Items.Clear()
           MedRoute1.Items.Clear()
    
           If MedType1.SelectedItem = ("Antibiotics") Then
    
               Dim dt2 As New DataTable
               dt2.Clear()
               Dim sql2 As String = "SELECT * FROM Antibiotics WHERE Antibiotics = '" & MedName1.SelectedItem & "'"
               da = New OleDbDataAdapter(sql2, cnn)
               cm = New OleDbCommandBuilder(da)
               da.Fill(dt2)
               Dim doses As String = dt2(0)(1)
               Dim dose As String() = doses.Split("-")
               For ii As Integer = 0 To dose.Count - 1
                   MedDose1.Items.Add(dose(ii))
               Next
               Dim routes As String = dt2(0)(2)
               Dim route As String() = routes.Split("-")
               itemRoute = route
    
           End If
    
       End Sub
    Last edited by Shaggy Hiker; Mar 19th, 2020 at 10:33 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width