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 5 Years Ago by Fa3hed: n/a

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.

Comments
thanks

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.