For Loop Running Backwards?
Sep 6, 2011Is it possible to make a For loop which count down. Like:
For i as Interger = 5 to 0
'Do stuff
Next
Is it possible to make a For loop which count down. Like:
For i as Interger = 5 to 0
'Do stuff
Next
I don't believe this is possible by conventional methods, but something like this verbose code: For Each s As String In myStringList Step -1 //' Do stuff here Next I will probably have to invert the myString object before a conventional For..Each Loop, correct?
View 9 RepliesIf I'm running a Do... Until or a For... Next loop in a button click event, is there a way I can allow the user to click the same button while the loop is running and escape the loop?
View 6 RepliesI am writing a program that is connected to an rs232 port and I need it to constantly be monitoring the incoming data. I think there are a few ways of doing this like checking the buffer but I need this to be running while I am connected to the port. I have a play button and a pause button for the port. When the play button is pressed, the port is open and the button is no longer enabled until the pause button is pressed. I need to have a while loop running the entire time the play button is no enabled, or pressed. I am having a hard time knowing where to implement it in the code.
View 2 RepliesI am iterating through the table rows . if the row row is null I just want to remove the row.[code]....
View 2 RepliesI'm developing a interface in VB.net which will control two stepper motors. Counting on your tips I managed to control them manually I mean, there're 4 buttons used to move the motors clockwise and anti-clockwise. The point is, the main part of our project is control the motors automatically. Our idea is based on two editable fields, X and Y, where the user would insert the displacement value he'd like the motor to move. After filling up both fields, the "GO" buttons would be pressed. So the loop would run depending on the displacement values in X and Y.
Attached you can find the main screen:
Below you can find the main code.
Public Class Form3
Dim velocidade As Double = 0.004
Dim X As Integer = 0
[Code]....
1. load gridview from an uploaded excel file (this would probably be about 300 records or so)
2. compare manufacturer, model and serial No to my MS SQL database (about 20K records) to see if there is a match.[code]is there a better way to find a match between the two?
Basically what I have are two loops, one inside the other, that will run until the given condition is met. Exactly what I want. My problem is that I want to be able to use the controls, like buttons, while a loop is going on.
I originally did not think of this until I had built this part of my program, what I want to know is if there is a way to use controls while a loop is going on or if their is an alternative.
1)I know timers can be used to meet these goals, but they did not work out as I had hoped and using two timers (1 to represent each loop) I do not believe is efficient.
2)I have considered using recursion, but have found this may not be very efficient either and am not quite sure if this will do what I want.
These loops run as long as the number the user inputted. So it could theoretically run for 100,000+ times. I am not looking for speed, but it would be good if there were a faster method that allowed me to use controls while it loops.
Windows Forms, VB application... Forgive me in advance for this very elementary question but I am overlooking something really simple here. I would like to have a label show the current value of a variable as the for each loop runs.. I created a very simple Button Click event to figure out where its failing. As it is right now the value does not display until after the for each loop finishes running, which it should actually display the counter value each time it runs through... I know this is possible and really simple because I did it years back but for the life of me cant figure out why I am missing the bar as it should constantly update the label to reflect that?Test Sub is as follows:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim counter As Integer = 0
For x As Integer = 1 To 200000
[code]....
I've been having a bit of a problem using the while function.
Here is my code (Simplified):
Dim RandomNumber3 As Random
Dim RandomOutput3 As Integer
[CODE]..............
When running the debug, the program crashes, and when I step into the program, I find that this While statement becomes an infinite loop. This is a program that uses random number generators to assign a value to something, and this while statement is necessary so that there is never two of the same values showing (RandomOutput, RandomOutput2 & RandomOutput) Have to be different to one another.
I am currently teaching myself the caveman code of Visual Basic (VB.net). Apparently I fail at If-statements or something, because I cannot get this to work...
[Code]...
While a "for loop" is running in VB.net, C# or Python which method can be used to append each result to a variable?
View 2 RepliesWhen it comes to threading. I've managed to adapt one of JMcIllhinney's backgroundworker codebank examples to somewhat suit my needs, but not completely. I have a main form, and a second form that appears while I'm running through a for loop. It informs the user what is currently happening. I set up a backgroundworker that allowed me to continue to use the main form during the for loop, but the other "status" form was completely frozen, and any labels or graphics were shown as white boxes. I am struggling to figure out how to be able to move/interact with both forms while the loop is running.
View 4 RepliesI'd like to make a simple program where my form consists of a textbox and a button. Here's the ide in a nutshell:in form1_load I invoke the sub:
private Sub LoopingLesson()
dim i as integer=1
while true
[code]....
what I want is when i hits certain value, like let's just say i is divisible by 365, then the 'while' looping will stop, and a message box saying "target reached" appear. then after I click button1, the looping will resume until it reaches the next number divisible by 365, and so on.
I have a simple application that I have to migrate backwards from ASP VB.NET 4.0 to 3.5 because of client limitations.
View 2 RepliesI need a small app that randomly shuffles a set of preloaded numbers. The shuffling will be visible on the screen and goes on continuously (looping) until a key is pressed and as soon as that happens it will show the winning number.Am using visual basics 2008 to develop the application but my problem is when i start the app and hit a key it will loop through my numbers on the text file and it will also display the event but if i hit a key to stop it will not stop..I was workin on the app but my problem is how to stop the loop and resume on the with a keypress. below is the app codes.
Dim Running As Boolean = False
Sub ReadAccounts()
Dim arr As New ArrayList
arr.Add("1366-665885-666-22650")[code]....
Does anyone know of any reason why my FilmID field (which is an autonumber) is going backwards? When I add a new record, it is going -1, -2, -3, -4, instead of carrying on from the last number. If you need the code, just ask, but I was thinking it might be something in properties or something?
View 3 RepliesI want to read a file starting from the last record and proceeding to the first record. How can I do it [if it can be done]?
View 11 RepliesWas just wondering, is VS .NET 2008 compatible with SQL Server 2000?
View 2 RepliesI'm working on a webcrawler in VB.net, and using the System.Forms.WebBrowser object for handling navigation on sites that use javascript or form posts, but I'm having a problem. When I navigate backwards (WebBrowser.GoBack()) to a page that was loaded with a form post, the page has expired and I have to do a refresh to resend the request. When I call a refresh (WebBrowser.Refresh()), a dialog box pops up to confirm. Is there a way I can get around this modal dialog in code?
View 3 RepliesI have.. Textbox1.Text = Textbox2.Text
I want it so that when you type text in Textbox 1, textbox 2 says it backwards.
Is there a command for this, if so how do I use it?
I have made an application with VS2010, meaning it requires .NET framework 4 to run properly.If the program is ran on a machine with .NET framework 3.5, it returns an error stating I should install 4.
View 7 RepliesMy WebBrowser1 keeps going backwards like 8 pages and then coming forward, I don't get it.
[Code]...
I could crop up a string to give me a cirten value.
The specified string involves a username, and a price, along with other numbers as a result of math.
"Would you like to buy "Relic TV System" from Demi0092 for $1,009?"
So in this situation I want to gather the "1,009" without any of the other text.
I have two textbox controls and I want to accept input for textbox 1 and textbox 2. However, when user enters text into textbox 1 I would like textbox 2 to mirror the same text as it is typed. I am sure this is a very simple procedure however it is new to me and I am having trouble finding an answer with search engines. Most result are coming back as text that one can read backwards in a mirror which is not what I am looking for.
View 1 RepliesSo work uses an Excel sheet with controls in it they designed a while back. however when they load it, all the normal text looks fine but the comboboxes and listboxes have backwards and upside down text. When i open the list options the text looks fine, but as soon as i select something it goes back to upside down and backwards. Anyone seen this before?
View 3 RepliesI am writing a program to be able to input a password and take that password and display a new password in a label. the new password will display the results as follows. Any vowels in the old password will be displayed as an x in the new password and numbers will be displayed as x's, and the last part it will display in reverse order so if I enter in timmy1 it should display zxmmxt. I do not know how to write the code to be able to reverse the string to be able to display the password backwards.
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
[code]....
Makes the following statement about the code below:
**"The computer evaluates the loop condition in the Do...Loop statment to determine whether the loop instructions should be processed. In this case, the inputsales <> String.Empty condition compares the contenst of the input sales variable to the String.Empty value. As you know the String.Empty value represents a zero length, or empty, string if the inputsales variable is empty, the loop condition evaluates to True and the computer process the loop instructions. *If on the other hand the inputsales variable is not empty, the loop condition evaluates to false and the computer skips over the loop instructions.
Based on the code I think it is the opposite: ...that while the inputsales value is not empty it should evaluate to true and process the loop and if it is empty it should evaluate to false and skip the loop?
See below.
Option Explicit On
Option Strict On
Imports System.Globalization
[CODE]...
I have a form with 3 textboxes and 1 button.textbox1 has tab index 0, and it's text = 1textbox2 has tab index 1, and it's text = 2textbox3 has tab index 2, and it's text = 3
View 2 RepliesI ran into this assignment that asks me to "create an application that allows the user to enter a word or phrse, then the Label should display that word or phrase backwards in all lowercase. For example, I enter "I read" Then the label should display "daer I" I try to do this with "Substring, Replace, etc", butnone of them work. Is there any particular method to achieve this assignment?
View 6 Replies