Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
For Each item As var1 In ListBox1.Items
            If item <> TextBox1.Text + "" + TextBox2.Text Then
                ListBox1.Items.Add(TextBox1.Text + "" + TextBox2.Text)
            End If
        Next


getting an error in var1 ..Can some body help me..its about my job..its at stake..pllzzzzz
Posted
Updated 14-Nov-15 1:37am
v2

1 solution

Look at your code.
What type is "var1"?
If you have defined it, is it in the same module? If you haven't, then what type should it be?

It's not a standard type, so we can't be any more specific than that...And frankly, since you are adding strings to the list box, I suspect it should be String anyway...

In addition, you can't do that anyway, because you are modifying the collection your are trying to For Each on - which is a very bad idea, and will cause a run time error.
 
Share this answer
 
Comments
Member 12119549 15-Nov-15 8:39am    
Thanks a bundle for your responce ..so what can i do to iterate through loop.
OriginalGriff 15-Nov-15 9:54am    
How would I know? :laugh:
All I get to work with is exactly what you show us: I don't know what the code is supposed to do, much less what you have in your List Box!
Member 12119549 16-Nov-15 2:07am    
i am fairly now to this stuff.. your laughter brought me more inspiration :(
OriginalGriff 16-Nov-15 4:31am    
Glad I could help give you inspiration!

And if you were being sarcastic, then that's a perfect example of what I mean. We have no context for your question other than exactly what you tell us - we can't see your screen, access your HDD, or read your mind. So I literally don't know what you are trying to do with that code, so I have no idea what to suggest. The laughter was to indicate "I don't think you are an idiot, but you need to think about it from our perspective".

Think about it from the POV of your car breaking down. You call the garage and tell them "It broke" and turn off your phone. They don;t know who you are, where you are, what car it is, what happened to it, what parts they might need, or what you expect them to do next. So far, you've told us "it broke, come and fix it" which isn't a lot better! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900