kasowitz
asked on
Trim Character from ComboBox text with source as Datatable?
Im using a datatable as the source of my combobox. Code looks like this:
With ComboBox1
.DisplayMember = "Account #"
.ValueMember = "ID"
.DataSource = MyDataTable
End With
I want to trim the first character from all the "Account #"s. My account numbers look like this S0000000001 , I need to get rid of the S. I have tried variations of Trim and Substring(1, 10) on both the combobox and the datatable with no luck. How can I do this ? Thanks for any help you can provide!
With ComboBox1
.DisplayMember = "Account #"
.ValueMember = "ID"
.DataSource = MyDataTable
End With
I want to trim the first character from all the "Account #"s. My account numbers look like this S0000000001 , I need to get rid of the S. I have tried variations of Trim and Substring(1, 10) on both the combobox and the datatable with no luck. How can I do this ? Thanks for any help you can provide!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, I didnt realize I could use the SUBSTRING command in the actual SQL Statement.
SELECT SUBSTRING([Account #], 2,11) as ID FROM TABLE WHERE [Account #] LIKE 'S%'
works perfect..thanks :)
SELECT SUBSTRING([Account #], 2,11) as ID FROM TABLE WHERE [Account #] LIKE 'S%'
works perfect..thanks :)
ASKER
I am doing a select statement on a SQL DB. "SELECT [Account #] FROM TABLE WHERE [Account #] LIKE 'S%' " Then using the DataAdapter I am filling the DataTable. From the DataTable I am populating the ComboBox.
So Im not sure how to do what you just said?