Loop Over Multiple Variables In A For Each In Program?
Mar 29, 2011I would like to loop over two string arrays but does not work.[code]...
View 4 RepliesI would like to loop over two string arrays but does not work.[code]...
View 4 RepliesI have a sub which requires multiple counter variables. Is there a more efficient way of doing this. My example is simple. Image if I had 20 separate counters I was trying to manage. I would have to create 20 separate variables and then increment each in the desired place in the code.
Dim Counter1 as Double
Dim Counter2 as Double
Dim Counter3 as Double
[Code].....
I am using vb.net with phpMyAdmin MySql database. While running the piece of code below, the program hangs in the for loop before the variables are assigned values from the data table(dt)...
'Check for appraisal period-----------------------------------------------------------------------
Dim sqlCheckDate As String = "SELECT * FROM tblappraisalsetting where appSetID=(select max(appSetID) from tblappraisalsetting);"
[CODE]................
I have 50 checkboxes for 50 american states. The user can choose all 50 or only 1( so basically any number he wants). Based on his choice, I want to insert or update the table in sql server 2008. e.g-
Color = blue and chk1=check, chk2= check and chk3 = check (chk = checkbox). now the user wants to ad 10 more states to this or remove these 3 and add 5 more. so u basically get the idea. the table in database looks like this - ID Color State_id there is a table called states, so stateid shall come from there. so how do i do a loop insert or update in vb.net?
I have code, shown below, that works all except for 1 thing: The variables being passed byRef get passed, but once modified in the else section of the "if me.invokerequired" code of RecordData, the variables are never updated in the calling function. To reiterate, the calling function does not receive the updated data that is in the variables custid and amt.When debugging, I see the data change in the else section of "if me.invokerequired", but once it returns from the callback the data is missing.[code]
View 15 RepliesI'm trying to use variables created within a loop, but I'm not sure how to do this. I've searched around on the net and there is a few recommendations to try and put what I require into a function then just call the function.
[Code]...
I'll try to be brief, In short im trying to add together a variable, (name = STRFinValue) within a For loop, I think the syntax should be:
STRTotal = STRFinValue +STRFinValue(f)
But I am very wrong.
Private Sub btnLBTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
[code].....
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim chatters As List(Of Chatter) = New List(Of Chatter) chatters.Add(New Chatter(New Guid("CD863C27-2CEE-45fd-A2E0-A69E62B816B9"), "Me")) chatters.Add(New Chatter(Guid.NewGuid, "Juan")) chatters.Add(New Chatter(Guid.NewGuid, "Joe")) Application.Add("Chatters", chatters)
[code]....
I am unable to understand last 3 lines that are bold and underlined. Please what is hppening here. Chatter and Chat are two classes defined in App_Code folder. Is there any sight that contains all possible ways to declare and initilaze variables and data structure:
Dim chatters As List(Of Chatter) = New List(Of Chatter)
how would I do a loop with different my.settings variables?
ie lots of variables
My.Settings.numberofsites = 3
My.Settings.SiteDesc1 = Home
My.Settings.SiteDesc2 = Work
[Code]....
This would give me an error as there is no variable called SiteDesc.... but I actually want it to return SiteDesc1, then SiteDesc2 etc.
what if you created a pool of numbers: 1 - 21 and then chose a random selection from the pool? Something like the following:[code]This gets rid of those messy if statements and all of those loops.
View 1 RepliesI need to assign variables dynamically in a loop. In php you would use curly brackets but this doesn't work in vb.
Dim i As Integer
For i = 1 To 12
lblMonth{i}.text = 'whatever
Next
Anyone know how I can escape the the i variable so it becomes part of the string that precededs it?
I am writing a program and i need to declare matrices but there will be a different number to declare everytime the program is run so I was wondering if anyone knew how to declare them inside a for loop
eg.
For i = 1 to NumberOfMatrices
Dim matrix i (5,5) As Double
Next
[code].....
This program asks the user for a number and then an amount to multiply it with and that amount should be added to the initial number. I need to loop because I am trying to display what the amount would be each day for a certain amount of days but in this loop its only calculating for the total .how to get the variables to change value to the updated day. I understand that its just keeping the same value in the variables I just need a push on how to get it to update the values through each loop.
I have some variables that are distinct by numbers, like in1, in2...If I have for loop, how would I access those variables, using the counter, and attaching it to the variable?I believe in JAVA, you could just use in+ct... where ct is the counter to access the variable.also how could you make a new variable in the for loop?Initially I had variables declare outside of the for loop. The problem was how to access those variables using the for loop.
var_nm1 = in1.Text
var_nm2 = in2.Text
var_nm3 = in3.Text
Dim nmList(2) As Integer
[code]....
This is object oriented programming, and I made the textboxes in1, in2, and in3 using the GUI editor. that was so easy.
In my loop I am trying to remove items from a list that have a certain name. I can't do this with a for-each, so I tried a regular for-loop. It seems the for loop is not working as expected. It always goes over the limit. I had to put an if-then to break out of the loop (very ugly solution). I'm trying to find the correct way to accomplish this. [code]...
View 1 RepliesThis is my first attempt at doing something in VB.net. I would like to be able to read a text file consisting of a column of data values and then pass the data as a variable to a sub that produces a line graph and updates it with each iteration through the loop. So far I have the code to read the file as well as some code that produces a line graph using hard coded values.
I am unsure how to call this sub from my loop such that I can pass that data value read from the file to the graphing sub.
How can I call the "PictureBox1_Paint" sub from my loop? How can I pass variables read from the data file to "PictureBox1_Paint" when I am calling it? Is there anything different that needs to be done if I want the graph to update with each iteration through the loop (for each data point)?
Public Class Form1
Private Sub Start_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start_button.Click
[Code].....
Here is what im trying to do. I have a loop and trying to concatenate it to produce the string. For whatever reason im getting test1, test2, etc instead of the variable equals to. What i am trying to do is get the value test1, etc.... from the concatenating test & cstr(a)
dim test1, test2, test3, test4, test 5 as string
test1 = "The"
test2 = "dog"
[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 RepliesWe have a project that needs to gather survey data. On one particular page of the website, there are 21 questions each with a scale of 1-5 where the user selects one radio button for each question in the table. The survey is being coded in VB.NET. The data submits to an SQL database. All the radio buttons are similarly named, so only the number changes for the question [Code]
View 2 RepliesI 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 RepliesIs there a way to give a value to multiple variables (integers in this case), instead of all at once?
For instance, I have Dim aceVal, twoVal, threeVal, fourVal, fiveVal, sixVal, sevenVal, eightVal, nineVal, tenVal As Integer and, pending listbox selection, I'd like to assign threeVal fourVal and sixVal all values of -1.
i would like to say i am a novice programmer, in year 12. I am designing a small game for my HSC and one of my forms is getting very cluttered with controls and code. To resolve this cluttering, i have had the idea to create new forms for some aspects of the game (such as different game modes and so on). However, in order for that to happen i have to drag some variables of the new form to the old form, (these variables would be just booleans or integers to say whether you lost a game or won a game or something that would carry on to the main form.)
[Code]...
I'm trying to set multiple variables using a textbox.The way I'm trying to do it is have each variable seperated by a space so like this:#If textbox1.text.contains("test") then set variables from textbox1.text for each " " in textbox1.text define new variable(value, string1, string2, int1, int2, int3, int4, int5)#End If I just don't know how I would code something that can set these variables from a single line of text in a textbox seperated by nothing other than just spaces.
View 1 RepliesI have 12 Varibales in VB.Net.
If a = 1 _ Or b = 2 _ Or c = 3 _ Or d = 4 _ Or e = 5 _ Or f = 6 _ Or...... Then
Like That....
For that my string will be so long for 12 varibles...
SO is there is any other way to compare 12 variables
I am trying to have it so that when a user hits a button to enter a shop, it will open a popup window which will have the shop's goods. The only problem is I can't figure out how to keep the variables working between the two windows.
I need to get the variable 'gold' to transfer to and from form2(the shop window) and whatever is bought at the store to transfer back to the main window.
Right now, when I go to form2 all the values are 0, and all the variables I used on form1 are undeclared on form2.
How do I access variables from form1 to show up in form2? Is there an easier way to accomplish this than using a separate form?
Is there any way to use a Select statement to Test multiple variables?
ie:
Dim x as integer = 1
Dim x as integer = 2
Dim z as integer = 3
Select Case x, y, z
What is the cleanest way to assign a value to multiple variables? For example, how can I assign FALSE to each of Label1.Visible, Label2.Visible, Label3.Visible, Label4.Visible, and Label5.Visible.Is there anything like
code
Label1, Label2, _
Label3, Label4, _
[code]....
This is my first attempt at writing a program that accesses a database from scratch, rather than simply modifying my company's existing programs. It's also my first time using VB.Net 2010, as our other programs are written in VB6 and VB.NET 2003. We're using SQL Server 2000 but should be upgrading to 2008 soon, if that's relevant.I can successfully connect to the database and pull data via query and assign, for instance, the results to a combobox, such as here:
[Code]...
How do I execute a query so as to assign each field of the returned row to individual variables?
I am wanting to get information from a text file into different arrays.
My current text file has a new line for each driver but I would like it to look something like this
[code]...
<pre-question blab>// skip if you want Might as well consider me new, as I haven't programmed in years, and that was only tinkering in Java. Trying to get back on track a bit, so starting with VB to get the feel going to continue learning. I don't mind putting in the effort to learn and look up, I just am not 100% sure what I should be looking into at the moment... Old programming I did was nothing advanced, only little things like calculators, notepad-esque writers, and that sort.</pre-question blab>
I'm BASICally wanting to know what I should look into for saving multiple variables of a custom class object to be loaded later. I've seen some things about text, and I can do that fine, but don't think it would be the proper/best way of handling things
at all. I also saw some talk of XML, SQL tables, etc. I just need a point in the right direction.
For a bit more info on my actual project, I was tinkering with a 'simple' program to allow users to create rooms/objects/etc., which will then be converted into Inform 7 language (an interactive-fiction language).The variables needing stored are objects with a number of string variables and integer variables. I need to be able to save those, then load them out later into an array of said objects.
For anyone needing a more VISUAL image of what I mean, here are a few screenshots to show you what I mean. Also, if anyone has ever used Adrift, it is (at the moment) very similar to it, but for the Inform language.
Screenshot 1
Screenshot 2