Escaping A Loop While It's Running?
Jun 22, 2010If 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 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 RepliesIs it possible to make a For loop which count down. Like:
For i as Interger = 5 to 0
'Do stuff
Next
I 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.
code to transform XML using XSLT: [Code] It worked fine until I came across this piece of data in an XML input: 34 &I40 #251. It doesn't appear to be escaping the &I40 properly. What can I do differently to make sure all of my data is escaped properly?
View 2 RepliesWindows 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 Replieshow to escape all special charecters.in this string there must be more than one escape charecters,for example
Q:95932010_03_02_Design_internal_work�1-ARCHPRESENTATION20100510Linkcad2010-05-192010_05_09_Townhouses Model (1)
in this there is "" , "("
is there any way to find out all this special ch like wise i wanted to escape all the special charecters in a string at once rather than finding and replaceing it one by one
I've got to generate html files with text data containing > < " and other punctuation and special characters. I 'manually' replace them with < > and " and I wonder can it be done using some .Net Framework class?
Also I'll be interested in 'unescaping' such sequences back to characters.
I'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 am trying to prevent from having to escape apostrophes in my string variables by using a parameterized query with a OleDbConnection, but it is not working. I am trying to insert into an Access db and I keep getting those pesky html codes.
Dim pConn As New OleDb.OleDbConnection
pConn = New OleDbConnection(cb.ConnectionString)
Dim SqlString As String = "INSERT INTO Strings (Mlt_String_ID, Lng_ID, Strg_Name, Sht_Text, Lng_Text, Alt_Text) Values (@Mlt_String_ID,@Lng_ID,@Strg_Name,@Sht_Text,@Lng_Text,@Alt_Text)"
[code]....
I have a block of HTML which I want to write to a file. It contains about 30 lines and it's difficult to escape all the double-quotes in individual WriteLine statements. In PERL, I can do something like the following to write inline HTML and print everything upto <<OUTFILE to outfile as-is, is that possible in VB .Net 2008?
print <OUTFILE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>GSC Signature</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.7930.16406"></HEAD>
<BODY><<OUTFILE
I could save the HTML in a template file and copy it into a new file each time, but that's not very flexible.
I am trying to prevent from having to escape apostrophes in my string variables by using a parameterized query with a SqlConnection, but it is not workinUPDATED: this is current code...
'Populate Connection Object
Dim oCnn As New SqlConnection(strConnection)
'Define our sql query
[code].....
In SQL I had to alias my column header with some text containing special character, So to mask these characters {}, I had to keep them in double qoutes.
eg: select column1 as "{Ctrix}" from table; When ran in sql the result is
{Ctrix}
-------
1
2
3
The problem that I got was while passing the same above query in the code that I had written in VB.strSQL="select column1 as "{Ctrix}" from table;" The query is getting truncated and giving error. Please help me, how to handle this properly at sql/vb... which satisfies both.
I 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]....
I have inherited a database that is moving to the web. Problem is that some of the string fields have html characters....
One example is....
"" without the quotes, IT WON'T SHOW UP IN HERE EITHER, trying something else. At any rate it has < and the > signs with text in the middle.
How can I escape any possible combination of html references.
SelectCommand="usp_getSingleStringData" SelectCommandType="StoredProcedure"
<SelectParameters>
<asp:SessionParameter Name="shrtText" SessionField="shrtText" Type="String" />
[Code]....
Question regarding fluent nHibernate table mappings:Apparently I was under the mistaken impression, that with an ORM tool, such as nHibernate, one could gain database independence - at least in table creation.Now, I have an automated toowhich creates fluent nHibernate mappings for me.It also works fine (though only if ALL tables have a primary key...)
Here a good representative example for such a mapping as it is created by the program
public class ELMAH_ErrorMap : ClassMap<ELMAH_Error>
{
[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 need to convert a string array into a very long string with following requirement:
can not using any character escaping can not using XML can not using single character as separator (e.g. comma or space as separator)
I had done one application using api which send the message to given number. The working of software is very fine without any error working on windows XP SP2. I heard that vista already contain the .net frame work so didnt installed .net frame work in machine. I checked in vista it shows .net frame work is in machine. But when same code i tried to run on Vista it gives the error. Error is as follows
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at SmsSendingApplication.frmSingleMessage.InternetOpenUrl(Int64 hInternetSession, String& lpszUrl, String& lpszHeaders, Int64 dwHeadersLength, Int64 dwFlags, Int64
[Code].....
I know I am missing the obvious. I would like a label to show how many cycles in loop are left.
[Code]...
I am constructing a program, i am new to Visual Basic, but i have past programming experience. I was wondering if anyone knew how to form a loop that could...lets say calculate the answer when two numbers are added together,and it would repeat this thousands of times, etc. And if there is a way, would it be possible to calculate the time taken to complete this loop.
View 5 RepliesI have written a function that gets the alexa ranking of a given url, now this function works perfectly but I want to loop through a ListView of urls and grab the alexa rank of each item (url) with my function.The code works great if I put a MessageBox in the loop to test that the function is returning a value but when I remove the MessageBox the loop does not work.I need it to loop through adding each result without a MessageBox stop in each loop.
vb
For Each Item In ListView1.Items
Dim result As Integer
result = GetAlexaRank(Item.Text)
[code].....
what account for this error message in ls beta 2?'' The last change wasn't successfully persisted.Please shot down the running application.
View 1 Replies