Iteration Using The Do-Loop?
Nov 15, 2011I just can't seem to understand when i am suppose to put Accept outside the LOOP and when i'm suppose to Accept inside the LOOP at the beginning.
View 4 RepliesI just can't seem to understand when i am suppose to put Accept outside the LOOP and when i'm suppose to Accept inside the LOOP at the beginning.
View 4 RepliesDoes a For-Each loop in VB have an iteration count, or would I have to do that myself?
View 5 Replies I've got a for loop. In my loop , I've got a condition , and if that condtion is not met, I need to move on to the next iteration.
So if I have :
For Each txt As Control In tbcell.Controls
if TypeOf (txt) Is CheckBox Then
[code]....
Does anybody know how to count the number of iterations in a for-each loop? I want to have a variable inside the loop, returning the corresponding counter every time the loop iterat
View 5 Repliesi have a for loop that is executing. i want while the loop is executing to be able to define using a variable how many seconds the For loop needs to pause before next iteration.
View 2 RepliesI'm using a DO interation to loop a function I'm using to test for internet connectivity. The code is working fine, except that when one of the tests is satisfied the loop stops. I want this to continue in the background while the program is running. How can I get this to work?
Private Sub checkInternet()
Dim InetChecker As Boolean
InetChecker = CheckForInternetConnection()
Do While LabelCount.Text <> ""
Thread.Sleep(10)
[Code] .....
i am developing a program in visual basic 2010, it involves a non- linear iteration of one of the two variables with a step of .00 and a match at the .000 (3rd) decimal placethere cannot be an exact match between the 2 variable's values but i need the iteration to stop at the nearest possible value.
View 6 RepliesIs the warning I am receiving about using the iteration variable in this line a concern.
Dim reportdataforpage = (From reportvar In reportdata Where reportvar.reportpage = pagenum)
how to assign one value to whole array without iteration through it? for example a i have pArray (5000,5000) =1 where all members off array = 1.
View 2 RepliesI have noticed that when iterating DataGridViewColumns, the speed is greatly reduced if the columns are visible.
For Each col As DataGridViewColumn In cData.DataGridView.Columns
col.Visible = visible
Next
If visible is set to false (and all columns are all currently visible), iterating 264 columns takes around 0.35s, however, if visible is set to true (and all columns are currently invisible), the same process takes around 30s.Does anyone know what would be causing the extra time?Could it something internal to the DataGridView Control?
Background: I am working on an ASP.net project that basically fills out a form from user input. The generated form (for reasons which I have no control over) must be a JPEG or TIFF. So the user fills out the web form, which takes all of the input values and meges them into a blank image (jpeg) of the form. Using System.Drawing, it merges all of the text onto the form at designated Points. The points are defined as variables which are modified at runtime to compensate for the resolution of the image (in case it get modified/re-generated at a different dpi). All of this is working fine.
Problem: Currently I have a Sub that determines the dpi of the master image, then adjusts the Points accordingly. However, there are ~50 variables that have to be adjusted. So currently I have the Sub go thru each point variable and manually adjust the X & Y values. I have been working on a Sub that will iterate thru all of the Point variables and do adjustment. Here's a functional sample of what I have working:Imports System.Drawing
Partial Class test Inherits System.Web.UI.Page
[Code]...
This works...sort of. It allows me to grab each variable and modify it, but only in the instance. The original variable in the class is unchanged. Which means that when the program gets to the point where it's drawing text to the image, the points are unmodified. my basic question is: Is it possible to modify the original variable using this sort of process? If not, is the best way to use these modified values to declare the new class instance at a global level, then have the Sub that draws the text use the instance versions of the variables?
I realize that I could define all of the points in an array which would be easy to loop thru and update, but I've named each point variable something meaningful to correspond to the related text to be drawn.
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'm flummoxed I'm using VB.Net, Linq, and a DataContext. My DataContext contains a table 'transactions'.
I first declare an IQueryable(Of transaction) and assign it to nothing. I build a predicate in a foreach loop and use a transactions.Where(predicate) to assign the IQueryable a value. If I do an IQueryable.ToList(), I get a number of items in the collection.
However, on the next iteration of the loop, the IQueryable.ToList() gives me 0 items.This is driving me crazy. I tried to use the LINQ to SQL Debug Visualizer with VS2010, (I recompiled the 2008 version with the new reference) but no dice - I can't see the SQl generated or what's inside the IQueryable.
[Code]...
I have List (of class). having 1800 of count and each object has 90 properties. When I terate earch with 90 properties taking more and more time. How to resolve this
Dim cellIntStyle As HSSFCellStyle = hssfworkbook.CreateCellStyle
cellIntStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("#")
Dim cellDateStyle As HSSFCellStyle = hssfworkbook.CreateCellStyle
[Code]....
[URL]..Module Module1
[Code]...
It says the result will always be 5 namely the final value of i. How come?
They don't put the iteration variable in the "closure"?
I want to create a (3n*7) Matrix in python through Iteration, I did this in VB.Net and it worked but it gives me some challenge in Python as this a new language to me. n can be the number of Iterations to build up the matrix, i.e. ; if u iterated 3 times, the matrix will be a 9*7 matrix. Here is how I did it in VB.Net. :
[Code].....
For Next Iteration To Sum Users Input Numbers
View 2 RepliesI'm designing an app that resets permissions on folders so I've made a treeview that uses GetDirectories to populate itself with all folders on a user's computer. The TreeView has the "checkboxes" property set to true so the idea is that users select all of the folders from this treeview that they want to reset permissions on and then click go.
So once they click go I need to loop through all nodes in the treeview and all subnodes etc and test to see if they are checked, then if they are I want to add each node to a list and then in the next routine I would loop through the list and reset the permissions.This is what I am doing at the moment but I keep finding that the objects added to my list are duplicated.For example if I select C:Test and C:TestTest2 in my treeview then I end up with my List looking like this:
[Code]...
I'm trying to create a structure wherin I have got 1 mother thread and 2 child threads. The child threads get variables to work with from their mother thread and after completion they report back to the mother with the resulting variables. I'd like to be as efficient as possible so creating a new thread every time a thread has finished it's work is kind of a no-go. How can I create this structure without creating a new thread for every iteration?
View 4 RepliesIs it possible to make this function iterative or must it be recursive?
The Function traverses a grid of x length and y height. At each point in the grid, it checks all of it's neighbors to see if they are valid, meaning they exist in the grid and haven't been used yet.
The function works in it's current form but I was wondering if an iterative version would be more efficient.
PathManip is a Stringbuilder, stores the path currently being manipulated. PathQueue is a List(Of String), stores all paths yet to be traversed.
IsPathAlreadyUsed is a boolean function that checks whether or not a specified point has been used in the current path.
Sub FindNeighbors(ByVal coords As String)
Dim x As Integer = CInt(coords(coords.Length - 2).ToString)
Dim y As Integer = CInt(coords(coords.Length - 1).ToString)
[Code]....
I'm using VB.NET. I want to build a large List (Of MyClassOrStructure) that becomes static after its initial population.I'm going to have multiple threads that need to iterate through this list to read data (no writing, inserting, or deleting)
Are there any very bad things that I need to keep an eye out for?
I have the following Enum:
Public Enum myEnum As Integer
first = &H1
second = &H2
[Code].....
Obviously I can code around this issue, but I can see a scenario where that workaround could be easily missed in maintenance programming, and I'm hoping someone can recommend a simple solution that won't break if, for example, the values in the enum have to change at a later date.
Does .NET have built-in techniques for more complicated forms of iteration like the following:
1. Iterate over rearrangements of a list.
2. Iterate over subsets of a list.
3. Iterate over all indexes of a multidimensional list.
4. Iterate over all "combinations" of a list, i.e. all subsets of a list of a given length, where subsets that differs only in their ordering occur only once total.
I recently had cause to do (1) and my method was ugly, slow, tedious, and generalized poorly, which is why I ask. I can think of better ways, but it was garbage code anyway [brute force checking that there are precisely 576 seven-digit numbers made up of 1, 2, 3, 4, 5, 6, and 7 that are also divisible by 11]. The others are just for my own curiosity.
I've been applying some recursive techniques to the second version of my app. This recursive procedure simply iterates through all nodes in a tree view and tests whether the text in the "department text box" matches the text name of a particular node. If there is a match, then the user's name, stored in the "name" variable, is added as a node to the node that has the same name as the department text box text.
[Code]...
Ok, so I'm making a program that will read from a text file, convert each line into an array, the. Send each of those lines 1 per tick. This is in 2010 Visual Basic. Closest I've gotten is sending all at once, I worked on it over night and am slowly destroying it. Ideally, I want Button 1 click to populate the array from the file at LocationTB then start the timer. The timer should send a line at a time on the GapTB interval.
Public Class Form1
Public TextLine As String
Public MyFileName As String
[Code]...
Code:
'array
Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces
'Need to output names 'adapter.Name' to another array for faster access.
'Iteration, slower
[code]....
I would like to put all the network interface names into an array without using iteration (For Each, For i).Is there a way to get the properties ie. 'Name' of an array object and be able to array.getvalue() their names?
I have created a simple application where I fetch questions from an Access database and store the answers to another Access database. I am not sure how many questions client would like to ask, so I can't hardcode that number.
So, column names for answers table (besides user information like first, last name and so on) will be a1, a2, a3 ... aN.
And finally the problem!
For testing purposes I have hardcoded saving first 3 answers like this:
newEntry.a1 = answers(0)
newEntry.a2 = answers(1)
newEntry.a3 = answers(2)
Now I would like to iterate through all properties based on count of "a-type" properties:
'aCount is number of "a-type" properties
For i = 0 To aCount - 1
Dim property As String
property = "a" & (i + 1)
newEntry.property = answers(i)
Next
Of course, above code does not work, it is just a pseudo-code idea that "should" to the same as my hardcoded example.
Is it possible to iterate through predefined properties of newEntry object in that manner?
I have a DataGridView with a single column that currently displays a short list of items. When the user clicks a button to run an update, each row/cell is read and processing begins. I would like to have the selection idicator move down the rows in the DataGridView as it completes processing of each record. How can I display the iteration of the DataGridView rows while the processing is underway? A redraw of the DataGridView or something.This is a VB.net windows form, I know how to do this with AJAX I think, but how can I in a Windows form?
View 1 Replieshow to raise an event.I have a class that does some calculation using a For... Next loop, from 0 to 100.How would I return the value to the main form AFTER each iteration is completed? How would I raise the event? I have read the documentation but I can't wrap my head around this.
View 8 RepliesIve got a few strings stored inside a string array, and i need to copy each string element into the integer variable on each iteration.how i would convert it? tried
CInt(stringArr(lc))
but got errors?