Jump to content
Heads Up! This website is no longer maintained, if your a member from our era, consider joining the discord to say hello.
Sign in to follow this  

Using Loops

Recommended Posts

You can execute multiple things in a sequence by using a Loop.

 

 

Dim i As Integer

For i = 0 to 10
'Code here...
Msgbox "Current number is " & i
Next

Share this post


Link to post

You can also loop a few other ways.

 

do until x = y
  'random code'
loop

 

do while x = y
  'random code
loop

 

You can of course use an inequality sign.

Share this post


Link to post

True that.

I just find the way i posted a bit cleaner and i can understand how its working better.

Share this post


Link to post

Heh, I'm the exact opposite.

 

I may be wrong but on the last line, shouldn't it read "Next i"?

Share this post


Link to post

Vb loops:

 

For-next: the overall best in my opinion. Perfect for looping for a predefined amount of times or forever

 

Do- they are good for when you don't know how many times you'll have to loop, however they are often buggy

Share this post


Link to post

Another way of doing a loop is this:

 

If x <= 10 Then
'Code Here
x = x + 1
Endif

Share this post


Link to post

Nice, but what about infinite loops? :S

Share this post


Link to post

If Stop = False Then
'Insert Code Here
End If

 

And just never set Stop to true unless you wanted it to stop lol

Share this post


Link to post

viper, that'd require a timer and alot of messy coding.

Share this post


Link to post

Good day to all of you sir. Can someone help me? I'm making a simple list VB6 project. Just for practice. And i have a problem. If I click "save" button, i want to save a data to database but before it save i want to search it first if the data had duplicate and prompts me..

 

For short i want Search and Save execute at the same button.. PLEASE I'm begging to all of you... PLEASE help me.. I'm a freshmen student...

Share this post


Link to post
Good day to all of you sir. Can someone help me? I'm making a simple list VB6 project. Just for practice. And i have a problem. If I click "save" button, i want to save a data to database but before it save i want to search it first if the data had duplicate and prompts me..

 

For short i want Search and Save execute at the same button.. PLEASE I'm begging to all of you... PLEASE help me.. I'm a freshmen student...

 

Well, in order to help you out, I'll need a little bit more of additional information about your project.

First off, what kind of data are you saving? Is it text? Numbers? A combination of both?

 

And when you click save, do you want the program to first check to see if you have duplicate data entries in the list you are making, before saving the entire list to a database?

 

And lastly, what format are you saving it to the database? Is it line by line? Or a custom format?

 

EDIT: To speed things up, we can contact each other via Instant Messenger Services. You can view my information through my profile.

Share this post


Link to post

while 1=1

{

//execute code

}

...A simple infinite loop?

Share this post


Link to post

He's asking for specific help on checking and storing information in his list and database. And he's working with VB6 as well, not VB8.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×