Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with formatting data entered in a list box from a Masked textbox


I am using three Masked input textboxes in the following format:

a. xxx-xx-xxx-xxxx
b. xxx,xxx
c. xx-xxx

When I enter the data in my textbox, for example format a, looks like 1305-98-987-7687

However when I copy the data to the listbox, it looks like 1-1305989877687

How do I modify the code below to copy the data to the list box in the following format

1- 1305-98-987-7687?  


Protected Sub ANSN_Click(sender As Object, e As EventArgs) Handles ANSN.Click
        C1NSN.DataBind() 'New Line
    End Sub
    Sub FormatListBox()
        For i As Integer = C1NSN.Items.Count - 1 To 0 Step -1
         C1NSN.Items(i).Text = i + 1 & "-" & C1NSN.Items(i).ToString    
         If i Mod 2 = 0 Then
         C1NSN.Items(i).Attributes.Add("style", "background-color: Yellow")
            End If
    End Sub
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

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