Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27435

add data for selected item in a listbox

$
0
0
Hello,
I've got difficulties in adding data for a listbox selected item.
Here is my code:
Code:


Public Class Form1
    Private mPatients As Dictionary(Of String, Patient)
    Private mCurrentPatient As Patient
    Private mCondition As String


    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim temp_patient As Patient

        mPatients = New Dictionary(Of String, Patient)

        temp_patient = New Patient("Dave", 1231234566, "12 / 11 / 1967")
        mPatients.Add(temp_patient.GetName, temp_patient)

        temp_patient = New Patient("Michael", 1232342133, "25 / 12 / 1978")
        mPatients.Add(temp_patient.GetName, temp_patient)

        temp_patient = New Patient("Phil", 3232321231, "01 / 04 / 1959")
        mPatients.Add(temp_patient.GetName, temp_patient)

        temp_patient = New Patient("Richard", 6766726320, "31 / 10 / 1965")
        mPatients.Add(temp_patient.GetName, temp_patient)




    End Sub
 

    Private Sub uiOKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiOKButton.Click
        Dim name As String
        Dim NHSnum As Long
        Dim DOB As String

        name = uiNameTextBox.Text
        NHSnum = uiNHSnumberTextBox.Text
        DOB = uiDOBTextBox.Text

        createPatient(name, NHSnum, DOB)

    End Sub

    Sub createPatient(ByVal name As String, ByVal NHSnum As Long, ByVal DOB As Date)
        Dim newPatient As Patient
        newPatient = New Patient(name, NHSnum, DOB)
        mPatients.Add(name, newPatient)


    End Sub

    Private Sub uiShowPatientButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiShowPatientsButton.Click

        uiPatientsListBox.Items.Clear()

        For Each kvp As KeyValuePair(Of String, Patient) In mPatients

            uiPatientsListBox.Items.Add(kvp.Key)
        Next
    End Sub

    Private Sub uiSelectPatientButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiSelectPatientButton.Click
        'Dim diagnosisDate As Date
        'Dim doctorName As String
        'If uiPatientsListBox.SelectedIndex = True Then

        '        For Each kvp As KeyValuePair(Of String, Patient) In mPatients
        'mCondition = uiConditionTextBox.Text
        'diagnosisDate = uiDiagnosisDateTextBox.Text
        'doctorName = uiDoctorNameTextBox.Text
        'Next
        'End If
    End Sub

    Private Sub uiConditionButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub uiStartDateLabel_Click(sender As System.Object, e As System.EventArgs) Handles uiStartDateLabel.Click

    End Sub

    Private Sub uiSubmitDetailsButton_Click(sender As System.Object, e As System.EventArgs) Handles uiSubmitDetailsButton.Click

    End Sub
End Class

The code put in comments under Private Sub uiSelectPatientButton_Click meant to add the information for a selected item of a listbox. However, the functionality is not working. I would appreciate to get the example on how to achieve the proper functionality here. Thanks in advance.

Viewing all articles
Browse latest Browse all 27435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>