Hey guys,

I have been working on this problem for a while and wanted to see if you could spot what the problem is. This form is used so I can add a customer to the list which calls up another form for the adding. And also has an option for deleting a customer off the list. Visual Studio is giving me an error for the procedure that refreshes the list. It is giving me an error when I try to add the break tab to separate the customers on the list. It is giving me an error about an Option Strict On not allowing implicit conversions from 'String' to 'Integer' What am I doing wrong? Here is what I have:

Imports Microsoft.VisualBasic

Public Class frmCustomerMaintenance
    Private customers As List(Of Customer)

    Private Sub frmCustomerMaintenance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        customers = CustomerDB.GetCustomers
        For Each Customer As Customer In customers
            Customer.GetDisplayText()
            Me.FillCustomersListBox()
        Next
    End Sub

    Private Sub FillCustomersListBox()
        lstCustomers.Items.Clear()
        For Each c As Customer In customers
            lstCustomers.Items.Add(c.GetDisplayText(vbTab)) ' This is where I am getting the error
        Next
    End Sub


    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim newCustomerForm As New frmAddCustomer
        newCustomerForm.ShowDialog()
        If newCustomerForm.Customer IsNot Nothing Then
            customers.Add(newCustomerForm.Customer)
            CustomerDB.SaveCustomers(customers)
            Me.FillCustomersListBox()
        End If
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Dim c As Integer = lstCustomers.SelectedIndex
        If c <> -1 Then
            Dim customer As Customer = customers(c)
            Dim message As String = "Are you sure you want to delete?"
            Dim button As DialogResult = MessageBox.Show(message, _
                "Confirm Delete", MessageBoxButtons.YesNo)
            If button = DialogResult.Yes Then
                customers.Remove(customer)
                CustomerDB.SaveCustomers(customers)
                Me.FillCustomersListBox()
            End If

        End If
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class

Seem to be that it is expecting you to pass an integer value in the c.GetDisplayText function but instead you are passing a tab string. Of course im only taking a guess here since I dont know what your function parameters are...

Can you post the definition of the GetDisplayText function?

EDIT: Just realized the problem was solved. ^_^; Nevermind!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.