Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm missing a namespace that I hope someone can point out for me. What I'm doing is populating a listbox then applying those results into a variable that gets passed back to a database.

 

However in my code I have this in a for next loop:

 

dim s as string

 

If listbox1.(I wanted to put GetSelected(nCounter) here but that option isn't available)

s = s & listbox1.items(nCounter) <-- nCounter is the variable for the for next loop however I get an error that says: "Operator '&' is not defined for types 'String'"

End if

 

 

I am assuming that I am merely not importing the correct namespace but for the life of me I can't think of one that I'm missing. Thanks to anyone that can help me out

Posted (edited)

Okay a little update......I have my form now doing (sort of) what I need it do. being a n00b I had to figure this out on my own and the following code is what I have:

 

Dim nCounter As Short
       For nCounter = 0 To printers.Items.Count - 1
           If Not IsNothing(printers.SelectedItem) Then
               print = print & printers.SelectedItem.Text
           End If
       Next

 

As you can see what I'm doing is populating a listbox with the currently installed printers then passing them back to a variable (thanks Robby) then updating that with a database. Which that procedure works.

 

However, if they select MULTIPLE entries then it updates the variable with the first listed printer however many times you selected another printer. For instance a user brings up this form, sees a list of 5 printers. He clicks on 1 and 5 then clicks the button to start the routine to update the database. But instead of updating the dbase with the names of 1 and 5....1 is listed twice.

 

I'm obviously missing something and I hope someone can help me fix this

Edited by pruebens
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...