Access Variables From Outside Of A Loop
Sep 15, 2010
I'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]...
View 2 Replies
ADVERTISEMENT
Jun 21, 2010
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].....
View 2 Replies
Jun 25, 2011
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)
View 1 Replies
Aug 9, 2010
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.
View 8 Replies
Oct 22, 2010
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 Replies
Jun 20, 2009
I 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?
View 7 Replies
Mar 23, 2012
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
View 4 Replies
Oct 3, 2009
[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.
View 8 Replies
Mar 29, 2011
I would like to loop over two string arrays but does not work.[code]...
View 4 Replies
Jun 6, 2009
I 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].....
View 7 Replies
Oct 15, 2011
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.
View 10 Replies
Nov 4, 2010
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 Replies
Feb 24, 2010
This 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].....
View 2 Replies
Sep 19, 2011
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]...
View 2 Replies
Jan 11, 2010
We 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 Replies
Sep 18, 2009
I need a good book for beginning to use VB 2008. I have some (limited) experience in using VBA. I want to access a database (SQL) and have access to the data set as variables?
View 6 Replies
Jan 5, 2012
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]................
View 1 Replies
Feb 1, 2012
Basically I just want to use
tile1.backcolor = colors.while (just an example)
however tile1 is only created WHEN the form loads, and it will not let me compile it becuase it's saying it doesn't exist
View 8 Replies
Dec 14, 2011
Public Sub drawChart()
Dim panel As Graphics = picBox.CreateGraphics
Dim myTextBrush As SolidBrush = New SolidBrush(Color.Black)
[code].....
View 1 Replies
Jul 23, 2009
I am making a small application in which i have added a class module and a window forms in vb.net. i want to acess the shared variables and mathods of class without making any object.
View 8 Replies
May 25, 2010
i Have two subs
Protected Sub Btn_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim Id as string = MyClass.getID
Private Sub Sub2(ByVal doc As Document)
' in here i need to access the ID from the above sub the Id needs to be in the btn_click sub cos it reates a unike id every time it is clicked.I am trying to capture the id at the time the button is clicked and store it on a variable.
View 3 Replies
Aug 25, 2010
I have a string on my main form called String1. When I open another form, I need access to this value. In the form I open, I have always done something like:Dim NewString as String = Main.String1
This has worked in the past. Well, I ended up renaming my forms (from Form1 to Main) in the property window and it now when I type the above code, it does not list Main as a form. Nothing that I renamed seems to exist now.
View 2 Replies
Mar 14, 2009
Asp.net has turned out to be alot easier to use than PHP (so far). However, I have been searching for a while and simply cannot figure this out. How do I get the variables that are contained in the url of my page (that originate from a form that had the method "GET") and utilize them? For example, my page would be [URL]. How would I get the value of some variable?
View 5 Replies
Oct 31, 2011
I have been charged with porting a VB6 project into VB.NET. In vb6, if you were in a class separate to a particular variable, you could access that variable easily:
Public Class Foo
Public k As Integer
End Class
Public Class Bar
k = 12
End Class
In VB.NET, my understanding is that before you can use a variable in another class, you must declare a new instance of it:
Dim foobar As New Foo
This would be fine, but I have to access these variables from different classes and every time I declare a new instance, it wipes all old values from the variables, which I need. I tried using Inherits statements but they presented many problems.
View 2 Replies
Aug 10, 2009
I have a variable called VarNUM which stores a number from 1 to 10. What i want to do with this is based on the current number stored in that variable call a different set of variables from a module with Public Structure ITEM1. It has the same set of variables for ITEM1 - ITEM10 but with different values. So ya in raps how can i use the number in one variable to access a set of different variables? Something like ITEM(VarNUM) then the set of variables that all have same name but with different values so that i dont have to go,
Code:
if VarNUM = "1" then
name = ITEM1.name
store = ITEM1.store
[code]....
View 10 Replies
May 8, 2011
I am developing a program where i will download and save an xml file from a url as abc.xml. I open the abc.xml in a datagridview with a dataset without problem.I am confused how can i read raw per raw the datagridview and assign the data in a database table? i am using vb 2008 + msde2005 express.I show the whole content of the xml file in the datagridview with the following [code]I dont know how to create a loop where i can read the datagridview line by line save data in variables (ex.strings) and save it in a databese table?
View 6 Replies
Jun 20, 2011
I'm facing a problem with my current member card reader development.
I'm reading the card number (just a serial number of 4 digits) with a card reader. this seems to work fine (even converting the text string to integers).
This number is then put in a query to find the exact record that corresponds with this number
Me.JSM_LedenTableAdapter.GetDataByKaartnummer(IntCardNr)
View 4 Replies
Jan 14, 2011
I am querying the MS Access Database to display the results in a datagridview. This is my
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data.mdb"
Dim SQLString As String = "SELECT * FROM Groups where Selected = Yes"
Dim OleDBConn1 As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(ConnString)
[code]....
The variable Selected from the query statement ("SELECT * FROM Groups where Selected = Yes") is a Boolean in the MS Access Database. However, this statement returns empty result even though most of the values for Selected are Yes. In the access database however, if I enter a 'Yes' for the value of Selected, it shows up as -1 and 'No' shows up as 0. So I even tried changing the query statement to ("SELECT * FROM Groups where Selected = -1") and also ("SELECT * FROM Groups where Selected = 'Yes'") but none of them work. Can you please help me fixing this query because I can't change the database?Also if I change the query statement to ("SELECT * FROM Groups"), then all the data shows in the datagridview, however, the values for Selected column do not display. Instead I see check boxes and I can't click them. How can I display the values correctly?
View 8 Replies
Nov 17, 2010
I'm tasked with the job of creating a javascript version of a units conversion application written in vb6. I have the source code but I don't have vb 6. The source code uses a dat file to hold a conversion array (unit type, unit, xfactor, plusfactor). Getting the data out of this file would be good to me. I tried creating a little app in vb 2010 to write the data from that dat file to a txt file using essentially the same code as the source code. And that has been somewhat successful (took a while to figure out the fixed string business). Now I can pull the data out as an array. The math elements of this array look fine but the strings are somewhat read-able but too garbled to use. I can't seem to fix that by changing the character set/encoding.
View 3 Replies
Apr 15, 2009
I have the following code:
Public Function StoreFields()
Dim Lockbox, Cash_Deposit_Date, Batch_Number
Lockbox = Xdocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:tbl_GC100/@Lockbox").Text
[code].....
I have tested the variables in the Functions and the are correct.
View 2 Replies