0

Hello Everybody
prop lame
i am making a access sql helper

and for writing the insert this code

Dim i As Integer
        TextBox6.Text &= "Insert Into " & ComboBox2.Text & " ("
        For i = 0 To ListBox1.Items.Count - 1
            TextBox6.Text &= ListBox1.Items.Item(i).ToString() & ","
        Next
        TextBox6.Text &= ")"

it works very good

example of the code

Insert Into Contacts (Address,ContactID,FirstName,LastName,)

,

i want to remove this access comma

Edited by Fa3hed: n/a

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by adam_k
1

Try:

Dim i As Integer
TextBox6.Text &= "Insert Into " & ComboBox2.Text & " ("
For i = 0 To ListBox1.Items.Count - 1
TextBox6.Text &= ListBox1.Items.Item(i).ToString() & ","
Next
TextBox6.Text.Remove(TextBox6.Text.Length - 1, 1)
TextBox6.Text &= ")"

That one line should remove the very last character, in your case ",".
I did not test this code, so it may not be PERFECT, but it should work.

Votes + Comments
thanks
1

or use

if i < ListBox1.Items.Count - 1 then textbox6.text &= ","

to insert the comma (,) character.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.