Link to home
Start Free TrialLog in
Avatar of mei_liu
mei_liu

asked on

problems with adding text into listbox

When adding data from text box into listbox, it will show zero in the listbox if the data entered in the text box is string and it will return numbers if numbers are entered in the text box. Could anyone let me know what is wrong with it?
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Can you show wath you have ?
Avatar of mei_liu
mei_liu

ASKER

Dim freetext As String
        freetext = Val(TextBox1.Text)
        If String.IsNullOrEmpty(TextBox1.Text) Then
            AddBtn.Enabled = False
        Else
            AddBtn.Enabled = True
            Me.ListBox1.Items.Add(freetext)
        End If
Do you want to add only numeric values ?

If you do Val(TextBox1.Text) it returns a number if it's numeric and 0 if it isn't.
Why do you use Val() function ?
Avatar of mei_liu

ASKER

No, we would need to add both numeric as well as text into the listbox.
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial