VS 2008 How To Loop Though Xml
Nov 12, 2009Dim xml As New XmlDocument
Dim rd As XmlTextReader
Dim wrq As System.Net.HttpWebRequest
[code].....
Dim xml As New XmlDocument
Dim rd As XmlTextReader
Dim wrq As System.Net.HttpWebRequest
[code].....
I assigned an integer as 1, and looped my program using:[code]I can recieve the packets without looping, but once i loop, i receive nothing.
View 29 RepliesMakes 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 keep getting a notification that the application is already open. I have multiple users in different sessions on the box, and I thought I coded it right, but for some reason it loops still, but only with this one app??
vb.net
Private Sub clinicalLaunchorSwitch()
Dim CurrentSessionID As Integer = Process.GetCurrentProcess.SessionId
Dim hwnd As IntPtr
Dim prc() As Process = Process.GetProcessesByName("open")
[Code] .....
Maybe I just don't understand Exit For yet? I want to do something like:
For each instance of x.exe then t = t + 1
then
exit for t# of times. Is this possible??
I am very close to finishing this function, what I am trying to do is a for loop which:
1) Grabs the value
2) saves the value in an .xml file for later use
Currently when I use a for loop to feed in my function I overwrite the hiddenFields.xml on every pass, instead of adding to it.
Calling function:
vb.net
For X As Integer = 0 To postingHiddenFields
Dim hiddenFieldsReturned As String = functionDealWithHiddenFields(HTMLResponse, postingHiddenFields, X)
Next
[Code] .....
So basically on every pass of the function I'm overwriting the values instead of adding to them.
The following code is executed at an interval of 60000 milliseconds.
[Code]...
I tried doing a step through starting at a break point i put at the For Each line. It will go inside the For Each loop but when it reaches the first if statement and it finds that if statement false it will not go to 'Next' and continue to execute the loop instead it goes to End Sub. I want to be able to view what is going on inside the loop, i think the final upload process works so it does do the loop, though i can't step through to view it.
I know it can be written better but the problem is: FOR loop is performed only first time BtnAdd1 is clicked. Why???? Private Sub BtnAdd1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd1.Click
[Code]....
I can't think of a better way to do this, what i have is this function:
vb.net
Function functionDealWithHiddenFields(ByVal HTML As String, ByVal numHiddenFields As Integer)
[Code].....
which usually contains: 4 so when i loop out the names, it loops the 4 results, 4 times, instead of just showing me the names 4 times so i can then store them
I currently have a grid of 30 buttons, (6 x 5). So I named them btn1_1 - btn6_5
When the board loads up (this is for a jeopardy game) I have this
code
For counter = 0 To 5
Btn1_#.text = counter * 200
Next
Is there ANY possible way to do that (replace # with the number of the counter.) I doubt there is, but it never hurts to ask!
As a side note, where is a good place to post the jeopardy game that I am making in these forums, i tried both the code bank and gaming forums but they are dreadfully inactive.... since it is in VB.NET, i was wondering if i could post it here.
It is still in the making, but I would really like some feedback as i worked hard on it and got stuck for 6 hours on the save/load feature that was getting messed up cuz of a difference from A and a lol.
I can't use the normal method, my controls (picture boxes) names contain numbers such as 00, 01, 02 etc which corrispond to my multidimenional array.
I'm attempting change the picturebox's values in a for loop via the counter in the loop, for example:
For i = 1 To 4
PictureBox(i).enabled = False 'Picturebox1 will be the first one(counter starts at 1)
Next
I basically need to access each one as I would with an array, I can't type the full names out, can only refer to them via their names + counter number because I don't know what control name I would be dealing with at that time in the loop.
I would like to know which object shall I use to make a loop within a table. I was used to work with recordset object, working with EOF function in VB6. Now I am lost.
View 3 Replieshow can i loop until the last row of a data grid
I want to loop through a series of rows
Dim num4 As String Dim found As Boolean
HERE HOW CAN I LOOP to check if a nummber its found and if it is found then condition = true if its not found when finished the list the n condition = false For ver = 0 To 1105 (IDK HOW TO LOOP SO I DID THIS BUT DOESNT WORK CUZ IT CHECKS row FOR row RATHER THEN ALL OF THEM)
[Code]...
The code below finds a string from a text file and, if the correct month, - Monthcheck1, adds it as an item to an unsorted ListBox. I want to run through the text file again to find data for the next month. If I repeat this code for MonthCheck2, nothing is added. My question is: What is the convention for looping through the same file a second or third time?
[Code]...
I have a few labels on my form:
LblBtn0
LblBtn1
LblBtn2
ect..
I would like to loop trough the labels using the following
[Code]....
i have a program that is going to be disabling services depending on what is selected by the user via check boxes, and it would also add to the log if it failed or succeed ( the dim xfailed as integer ). There are a total of 73 options for services and i didn't feel like copy and pasting IF THEN statements for all 73. I was wondering if i could make a loop out of this?
The x would be the service name - ex. "Themes"
Dim x as serviceprocess.servicecontroller = new serviceprocess.servicecontroller(x)
dim xFailed as integer
Try
[code]....
I have a loop set up as [code]I need to know a way to break that loop at the current item it's on in the listbox (listbox1) via a button click (button8)
View 5 RepliesI was wondering if there was any way to stop a for loop untill i have user input, once the input is correct continue the for loop, is that possible at all
View 3 RepliesThe problem is that the code is in a loop which i'm not sure how to stop.The need the text file to read all the file extensions.So i start looping through all the files in a folder.The other problem that happens is that i also need to loop through all the files in the folder so that i can compare the string line and the string X. So the final result is that my program is in one giant loop.
[Code]...
I m trying to use two datareader in same loop but its not working. Here is the error and code below Error line: DR1 = MyCommand.ExecuteReader()Error message: There is already an open DataReader associated with this Command which must be closed first.
[Code]...
I have about 1.000 text files in a folder, and I wanto to make some statistics reading the files content.In the first place I store the files path + name in a MyFiles() array, then, when I press a "Start" button I read the several files:
For x As Integer = 0 To MyFiles.Length - 1
FileReader = My.Computer.FileSystem.ReadAllText(MyFiles(x))
(data processing)
(data processing)
next
then I have copied and pasted the first 500 files in a new folder and added to the code if x > 500 the stop The strange thing is this: to elaborate the 500 files of the second folder takes about 4 seconds, to elaborate the first 500 files of the first folder (THAT ARE IDENTICAL TO THE 500 FILES OF THE SECOND FOLDER) takes 7 seconds.The same identical code takes different times to elaborate the same identical files if they are stored in different folders with different files number.
I need help to optimize this
For x As Integer = 1 To Me.dtsCustomers.Tables(0).Rows.Count Try
'I SEND VALUES: NAME CUSTOMER AND HIS AMOUNT
Dim client As WebClient = New WebClient<br/>
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
client.QueryString.Add("customer", Me.dtsCustomers.Tables(0).Rows (x).item("customer"))
client.QueryString.Add("amount", Me.dtsCustomers.Tables(0).Rows(x).item("amount"))
[Code]...
I have a question, i have worked in several languages in my life (including several versions of basic) but i wonder whether in .NET using a variable or equation in a loop is a lot slower than not using one? Take the following identical loops
Dim test(999) As Integer
For count As Integer = 0 to 999
test(count) = count
Next
[Code]...
Now the 2nd case is good because it is easier to adjust the code should the array size need to change yet my background tells me the 1st case is the one in terms of performance, test.Length - 1 is calculated each time the loop runs. a loop of the 2nd kind for example has a massive effect on java as well as VBscript or javascript.So heres the question, would test.Length - 1 be calculated each time the loop ran, or just the first time?
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 am writing an application to compare each item on listbox1 to all items on listbox2. If the item is found, then remove it from both lists. The goal is to only have the items that were not found remain on both lists.
The problem is, the application just hangs and I never get any results. I looked at my code several times and I cannot figure out what's going on (programming noob I know.
[Code]...
I have the following Method:
CODE:
Everything is working fine except for one part. The part where the second foreach loop runs. If I only have one plugin installed it puts 2 entries in the list. The reason is because it has 2 rows and it is adding it twice. I know what the issue is I just am drawing a blank right now.
I am making a program thats going to be an msn style popup for reminders. I made an infinite loop to activate the popup when the date = current date. However its stuck in the loop and I cant run other functions while the loop is running. How can I get the alert to go off while also running the program?
Public Class Form1
Structure List
Dim Name As String
Dim Day As Date
Dim Hour As String
Dim Min As String
[Code] .....
I thought I could use this, to loop through all checkboxes in a frame:
For Each cb As CheckBox In Me.frameSearch.Controls
cb.enabled = False
Next
But it walks through once, then it comes with error:
Unable to cast object of type 'System.Windows.Forms.Label' to type 'System.Windows.Forms.CheckBox'.
There are indeed labels within 'frameSearch', but I thought that the "For Each cb as Checkbox" would loop only through all checkboxes..? Following does work, but it seems a bit of waste of CPU time, since it will loop through all controls!
For Each cb As Control In Me.frameSearch.Controls
If TypeOf (cb) Is CheckBox Then
cb.Enabled = False
End If
Next
How to do this more effectively?
I am doing a project. I want smooth progress bar that shows progress of EACH loop. Lets say I have a loop, (the amount of steps of loop is dynamically determined according to input of the user) but each loop will perform 4 or 5 steps.
Like collect data into string
RegEx
Submit form to http using web.UploadData
Get result data
Arrange data using regex
Display output in a multi line text box ( append data for each loop)
Now as I said there are unknown amount of loops that will perform above steps. What I am trying to do is : make a smooth progress bar which will show progress of one loop and then reset to zero and start over again as second loop is started. Like this :
ProgressBar.Maximum = 100
ProgressBar.Step = 25 ( for 4 steps )
For each data in dataArray
[Code] .....
Now I want progress of each step displayed in the progress bar smoothly. Like the one when we copy a big file to another location. Each loop takes about 5 - 10 second time (depending on the internet speed, as it submits a form and gets output.
Dim t As String = source
For Each m As System.Text.RegularExpressions.Match In System.Text.RegularExpressions.Regex.Matches(t, ">.*?<")
search = m.Value.Substring(1).Remove(m.Value.Length - 2)
If search = "" Or haku = " " And counter < 337 Then
[code]....
What you see here, is a code that picks everything written in between > and < markers from a source code on a website. What it returns is always a time stamp in between 00:00 and 23:59 and a string. Or almost always. There is a few instances where there are two times in a row and not every other, effectively breaking the system.Also, when this happens, the first time of the two has a "-" after it, i.e 18:00- What I've been trying to do, is making the program recognize when there is an extra character (the -), delete the extra character, and then jump over the next result in the search (the following time). This would completely resolve the problem.
The thing is, no matter how much I go through it in my head, I can't seem to think of a way to affect the NEXT result without screwing up the current result or all the following results. As you can see, my code is faulty. What it does now is an emergency method (as my teacher review of the code is coming up real soon) it jumps over the time with the extra character, and lists the following time. This however is not ultimately wanted, because in the bigger scheme of things, it displays the incorrect time for the incorrect string.
Search variable holds all the results of the regex search, for easier handling, and is used for checking for the extra character.Length6 variable is boolean for determining if the result had the "-" or not. The column ariable is to list the time and the string on the same line in the textbox.Jump is the variable that makes the code skip the conditioned result from the search.The counter variable, that might seem extra, is just for extra conditioning, its use is to prevent the first 337 instances of the search.