VS 2008 Using Loop Variable As Array Selection?
Oct 10, 2009
Lets say I have declared an array by doing:
dim array()
Also have a variable:
dim loopsize = 10
Then i do this:
for loop = 1 to loopsize
array(loop) = 5
next
What i wanted to do with this is from array(1) through to array(10), the values will be changed to 5. But vb will not allow this and crashes.
Why doesn't this work and how can i make it work?
View 4 Replies
ADVERTISEMENT
Dec 29, 2011
Code of my web page.I made changes according to ur suggestions but title is invisible or not displaying what has missed by me [code]...
View 1 Replies
Dec 12, 2010
the problem - i have a list box, which i use to display info (obvs) but when i click on one of items in the list when debugging, i wondered if there was a way to store which one was selected in a variable?
dim selected as string
selected = 'vb variable for a click?
View 1 Replies
Mar 18, 2010
Found this:
Sub SurroundWithAppendTag()
DTE.ActiveDocument.Selection.Text = ".Append(""" + DTE.ActiveDocument.Selection.Text + """)"
End Sub
But I can't seem to figure out how to loop through each line of text in the selection.
View 1 Replies
Mar 6, 2011
I have a 2D array which holds 5 students and two test results. I have initialised my array as studentTestResults(4,1) However, I am looking for a sorting algorithm which will displays the students in order of combined results when the user clicks "sort results". I have had a hard look around the net, but finding a bubble sort for a 2D array is difficult, especially as my knowledge is minimal.
[Code]...
View 4 Replies
Nov 21, 2009
I have an array of structure and need to sort it using selection sort. I have to sort the array by the last name field in ascending order (A to Z). I dont understand how to use the selection sort method.
The code i have so far...
Public Class frmMain
Structure EmployeeInfo
Dim first As String
[Code].....
View 5 Replies
Jul 11, 2009
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]....
View 8 Replies
Feb 28, 2009
I use a simple for each loop toi grab a piece of data from a regex like:
[Code]...
View 7 Replies
Mar 25, 2010
Im in a programming class and im having trouble with two problems.
Problem 1.
1. Declare an array of data type Integer with size 10
2. use a for loop to initialize the array with 1, 2 or 3 using given random number function below
3. display content using msgbox.
'paramaters
'low - the lower bounds of range
'high - the upper bounds of range
'returns
[Code].....
View 1 Replies
Dec 15, 2010
I am trying to loop through a jagged array and keep getting an exception.
Dim jagged()() As Integer = New Integer(1)() {}
Dim test() As Integer = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}
For i As Integer = 0 To 1
[code]....
View 9 Replies
Aug 2, 2011
I am trying to create a program that the user enters the number of enrollments for 5 different campuses during two semesters. I just got started and here is what I have so far but when I run the program it is stuck in an infinite loop and will not go to the next function. I am not sure how to end the loop. Here is what I have so far:
Module Module1
Dim SIZE As Integer = 5
Dim campus() As String = {"Decatur Day", "Decatur Evening", "Huntsville Day", "Huntsville Evening", "Distance Learning"}
Dim semester() As String = {"Fall 2010 semester", "Spring 2011 semester"}
[Code] .....
View 10 Replies
Jan 31, 2010
I should be able to pass an array of numbers, calculate average, lowest number, highest number, and standard deviation.the function returns an array containing the results. I dim public data
Public dataArray() As Double
Public DataIndex As Integer = 4
Private Function CalculateData(ByRef dtArray() As Double) As Double()
[code]....
I get an "error Number of indices is less than the number of dimensions of the indexed array" stats()If I add a dimension there like stats(Dataindex) I get an error "Value of type '1-dimensional array of Double' cannot be converted to 1-dimensional array of double".
View 2 Replies
Jan 23, 2012
I have a list with several fields that is created from dataset from a linqtosql query. At run-time, the user gets to specify what field he/she wants to display from the list. In other languages, I can dynamically do this like:
valueIwant=mylist(i).[fieldnameImInterestedIn]
Where 'fieldnameImInterstedIn is itself a variable. How do I do this in VB.Net?
non-working actual code follows:
Dim patientdata = (From patientvar In pdfdatacontext.tbPatients Where patientvar.PatientID = patientid)
Dim patientlist = patientdata.ToList()
fieldvalue=patientlist(0).(reportrow.userselectedfieldname)
View 1 Replies
Sep 7, 2011
here is some simple code:
0: dim varA = 0
thread.sleep(1000)
GoTo 0
I was wondering how do I name each new variable a different name each time through the loop (i.e. varA1, varA2, varA3)
View 8 Replies
Jun 12, 2011
I am trying to create a program that the user enters the number of enrollments for 5 different campuses during two semesters. I just got started and here is what I have so far but when I run the program it is stuck in an infinite loop and will not go to the next function. I am not sure how to end the loop.
Here is what I have so far:
Module Module1
Dim SIZE As Integer = 5
Dim campus() As String = {"Decatur Day", "Decatur Evening", "Huntsville Day", "Huntsville
[CODE]....
View 1 Replies
Nov 16, 2009
Im looking for help with trying to vary a variable-name in a for loop:
For b = 1 To Count
' the below image_var(b) varible needs to vary on each iteration'
Dim image_var(b) As New LinkedResource(Server.MapPath(myArray(b-1)))
' need also to have the b in myArray(b-1) bit work through the loop too'
' that is I''m after the array index b minus 1'
image_var(b).ContentId = "imageContentId_" + b.ToString
[Code]...
View 3 Replies
Jan 30, 2011
what's the difference between variable array and object array?
View 7 Replies
Jul 15, 2009
What type can i assign a for loop control variable? I want the for loop to be the output file of a calculation, but i can not define it as anything, and i do not know how to write it so that the output is actually what the code spits out once the code has finished running.
[Code]...
View 3 Replies
Feb 23, 2010
this is my code -
for i as integer = 0 to rows.count - 1
output &= "Name =" & row(i)("Name")
output &= "lastName =" & row(i)("lastName")
[Code]....
is there a way to make a for loop and run applicant 1,2,3,4.... in one shot?
View 3 Replies
May 10, 2012
I'm working in VB.net and I want to create a generic ToString. is there a way to do a "For Each" in "Me".
[Code]...
View 1 Replies
Mar 25, 2010
I am getting the error:"Range variable 'sender' hides a variable in an enclosing block or a range variable previously defined in the query expression."for this
Imports System.Data.SqlClient
Imports System.Linq
Public Class Form1
[code]....
I can select any other item from the table without the error. "sender" has the same properties as "receiver" in the SQL table.
View 2 Replies
Nov 19, 2009
The subject almost sums this up. I have dimensioned a variable 'y' inside a for loop. If i then try and access this outside of the for loop I cannot. What is the reason for this and how can I correct it? Unfortunately I am not able to Dim the variable 'y' outside of the for loop.
View 1 Replies
Nov 1, 2011
I have a mvc 3 vb.net app that I need to generate several viewbags for... I tried the following code to just drop a variable at the end of the viewbag name after each loop but it wont take it.. It says "Object variable or With block variable not set." when it his the viewbag.status(p) line on the second pass it makes through the loop...
Dim p As Integer = 0
For Each registrant In b
Dim _regi As attendance = registrant
[code]....
View 2 Replies
May 14, 2009
Is it possible to define two variables in a vb2005 For loop in a similar way that jscript does it?
the javascript example is
for(i=0,l=0;i<20;i++){}
View 1 Replies
Mar 30, 2010
Using VB.NET .NetFramwork 3.5. This fails and strikes me as odd. Is this correct behavior:
Public Sub TestForEach()
For index As Integer = 1 To 10
Dim z As Integer
Assert.AreEqual(0, z)
z = index
Next
End Sub
I would expect z to always equal 0 as I thought the dim-ing of an integer would set the value to 0. If you run this. It fails at the second loop. For some reason z retains it's value of 1. I know I can manually initialize z to = 0, but I wanted to know if this is a bug or expected behavior.
View 9 Replies
Jan 12, 2010
I have a button that searches through a binary file to bring up customer information with the following code:
[Code]...
My problem is, I need to create a variable which holds the record number, so that the record can be edited, and put back into the file at its previous location, how would I implement this? Not sure about the code.
View 3 Replies
Jan 26, 2009
I'm multiplying X*Y*Z in a loop of 200 interations Y is declared as a constant. A timer can cause the loop to pause for 10 seconds.
During this 10 sexond pause I would like to change the value of Y. It needs to be changed only for this run, not a permanent change which can be done in the declaration.
View 1 Replies
Jan 27, 2012
wondering about the relatively efficiency of declaring oop variables in the loops, emselves, or declaring them before first use. Here are some examples:Declare early:
Dim ix As Integer
Dim currentNode As System.Xml.XmlNode
For ix = 1 To 100
[code].....
View 9 Replies
Aug 26, 2011
For i As Integer = 1 To 10
Dim j As Integer = 10
Next
now my question is, Is memory allocated to j every time its executed inside for loop? or only value of 10 is assigned on subsequent iterations?
View 2 Replies
Feb 9, 2010
how to "loop through a datagrid column to add values to a variable
in VB6 it was something like:
do while not .eof
myvariable = myvariable + datagrid1.collumns(6)
loop
View 6 Replies