VS 2008 Cleaning Up A Nested For Each-loop?
Dec 3, 2009
I'm comparing a temporary table to an another table, to check for changes in the cells. The way I'm doing it, is that I'm using three loops; one to loop trough the temporary, one to loop trough the other table and a last one to loop trough each column. Here's the
vb.net
For Each row As DataRowView In View
For Each drow As DataRowView In view2
[Code]....
"emitid" is the column I use as a reference to be sure that I'm comparing the correct rows, and the column order will always be the same in both tables.
View 4 Replies
ADVERTISEMENT
Jul 29, 2010
I'm gathering a list of files within a directory and then adding them to a ListView:
VB.NET
For Each f In Directory.GetFiles()
Dim lvi As New ListViewItem
lvi.Text = f.Name
[code]....
The exclusion list works great, but it duplicates each item in the ListView several times. How many depends on how many items that it excludes.
I understand why it's happening, but I can't figure out a way around it. I have to loop through the items in the ArrayList so that I can compare them to the other items.
View 5 Replies
Sep 24, 2010
so far i got
code
For Each item As Reflection.FieldInfo In GetType(NameSpace.ClassWithNestedClasses).GetFields
rtfAppend(item.Name & ":" & Tab & item.GetValue(Me))
Next
For Each item As Reflection.PropertyInfo In GetType(NameSpace.ClassWithNestedClasses).GetProperties()
[code]...
which gets me the simple string vars and properties of my top class, but how can i apply this to loop through all sub classes and get there vars and props?
View 1 Replies
Mar 15, 2011
how do i get out of nested for or loop in vb.net?
I tried using exit for but it jumped or breaked only one for loop only.
how can i make it for the following:
for each item in itemList
for each item1 in itemList1
if item1.text = "bla bla bla" then
[Code].....
View 4 Replies
Dec 2, 2011
I intended to do another SQL query inside here and retrieve data from another table by using the "category_id".I know the problems that asp.net required me to close the data reader before proceed to another query. But is there any solution for me to do another query and open another data reader within the opening data reader? [code]
View 2 Replies
Jan 15, 2011
I have a master file and a reference file
The outcome i need is a record of matches and also non matches from the reference file
Using a loop and conditional i can find the matches
[Code].....
View 5 Replies
Nov 4, 2011
how to create this sequence using a for loop and/or nested for loops?
1
2
3
[Code].....
View 2 Replies
Jul 9, 2011
Looking on different sites, i'm getting difficulty in understanding nested for loop. About how it works?
View 8 Replies
Dec 3, 2010
Dim cv As Integer
Dim cc As Integer
Dim CurrentValue As Double
Dim ObsoleteValue As Double
[code]....
Basically this code works for the first column of the DataGridView. It sort of stops iterating after the last calculation of the row is performed and doesn't change the cc value at all. Meaning the loop gets stuck after the first iteration.
View 1 Replies
Aug 18, 2010
I'm trying to make a simple game tree.Previously I used nested loops:
[Code]...
View 10 Replies
Aug 28, 2009
OK, after trying to get this working for a couple of days now I decided that I would turn to the experts here. I am trying to create a nested loop with a variable amount of nests. Let me elaborate. I have a program that first asks for the minimum and maximum amount of loops, I currently have a SELECT CASE statement that addresses each level of nesting individually.
Dim cMin As Integer = InputBox("Min")
Dim cMax As Integer = InputBox("Max")
Dim c1, c2, c3 As Integer
[Code].....
View 2 Replies
May 11, 2012
So I have some vb.net code, and I have a nested For loop inside a For loop, and then I have EXIT FOR statement, will it break out of one loop, or the whole chain?
View 2 Replies
Feb 7, 2011
I have the following string which I need to get onto one line for database storage and retrieval purposes:
{"id":8,"heading":"heading goes here","content":"<p>
content goes here</p>
"}
[code].....
View 2 Replies
Jul 20, 2010
Basically if i wanted my controls to be checked at startup id use a setting obviously
'UI Settings
chkCloseToTray.Checked = My.Settings.CloseToTray
chkAlwaysShowSystemTrayIcon.Checked = My.Settings.AlwaysShowTrayIcon
[code].....
View 3 Replies
Mar 21, 2012
I have a question regarding VB.net and the use of rsData connections to an SQL database.Basically we have a few inline pages that will display course information of courses that my institution runs. The code will connect to an SQL DB and pull through live data directly in the following format.
html += "<tr><td>" & rsData("M_Start") & "</td><td>" & rsData("WEEKS") & "</td><td>" & rsData("DAYSTIME") & "</td></tr>"
Now I was wondering if people would suggest pulling directly from an open DB connection or map the RsData results to strings? All data connections open and close after they have done their required portions and we have around 5 different procedures that occur within the page.
View 1 Replies
Jun 22, 2009
if i have a string like 12.4.23 how can i clean the dots? i want 12423
View 2 Replies
Nov 21, 2011
I've been making a game using a Console Application as the main window, for the it. The game requires you to make the right choices in a mini Hacking adventure, but I'm rather stuck in an area where the player is required to enter the name of the file they would send and the program does not recognize the right one, also I was wondering how I could tidy up my code as It seems to be growing at a unnecessary rate.[code]
View 6 Replies
Nov 28, 2010
I am just starting out with a practice VB project which involves selling donuts and coffee. I have written out the code which the program works but the code is very messy. This program contains functions and radio buttons to calculate a subtotal, tax, and total due. There are four variety of donuts in Group Box 1 listed as: Glazed at .65 each, Sugar at .65 each, Chocolate at .85 each, and Filled at $1.00.
The coffee choices in Group Box 2 are listed as: None at 0.00, Regular at $1.85, and Capuchino at $2.50 each.I want the cashier to be able to select a radio button to choose between the donut choice in group box 1 and then choose one coffee choice in group box 2. A textbox calculates the subtotal, a textbox calculates a tax of 3%, and a textbox calculates the total due adding the subtotal and tax.
Everything works fine but Ias I said before it is quite messy which I keep making it worst.I need to write one function to calculate the donut, one function to calculate the coffee, and one function to calculate the sales tax. Then I need a sub procedure to clear the subtotal, sales tax, and total due amounts when a radio button is clicked.I have been working on this for the past month ,code I have so far:
Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()[code].....
View 4 Replies
Sep 11, 2009
first, what is the base minimum that windows needs open to run... ex. svchost.exe, explorer, etc.
Second. is there an easier way to close all programs except the ones i want to stay open, i want to keep the needed basics open and my program, which will open other programs, but i want to make sure nothing else is running so that things will go as smoothly and as fast as possible. I just don't want to manually check what processes need killed and place them in the program one by one, i want to kill all but a few.
Extra credit... stopping all unneeded windows services would be nice too, but that would probably be too long of a process to worry about, and not really worth it considering the benefit of speed it would give.
View 3 Replies
Jan 6, 2012
however there is a portion in this code that can be simplified more (the if orelse statements). I know it has something to do with a collections class or an array, but I'm stumped on how to change it.
Function GetLastName(ByVal accountName As String) As String
Dim lastName As
Dim stringArray As Array = accountName.Split(" ")
[code].....
View 1 Replies
May 5, 2012
I've rearranged the error messages to different spots with no luck. The txt row need to be a number 1 to 10. The txtSeat need to be A,B,C, or D and the txtPassenger shouldn't be left empty.
Public Class Form1
Dim seat(9, 3) As String
Dim waitingList(9) As String
Dim passengerNames(9, 3) As String
[code]....
View 8 Replies
Nov 11, 2010
Not sure if this has been asked before (couldn't find an answer), but is there a way to reuse a user.config file from a previous version of the application? For example a user.config file is stored in:
C:UsersJohnnyAppDataLocalCompanyApplicationName.exe_Url_wxcnyrmstqy3oj1qwckdjq3gjqkq4fel1.0.0.0user.config After a new version is installed it gets stored in:
C:UsersJohnnyAppDataLocalCompanyApplicationName.exe_Url_wglmejvw01nagu5t1y5yl12chynjomny1.0.0.1user.config The user then has to enter all settings again, even if the new version does not save more settings. An other problem is that although the user.config file is very small, it does get messy after a while when newer versions of the application get installed. Is there a way to clean up the unused user.config files and their folders?
It's the same problem with System.Windows.Forms.Application.LocalUserAppDataPath, that I'd like to use to save other files (containing Listview data), which points to:
C:UsersJohnnyAppDataLocalCompanyApplication1.0.0.0 The Listview data and other files created by the app can't be used anymore.This can be solved by getting the user's appdata folder with Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) and creating a new folder there with the name of the application. But this means there's one folder where the application is installed (user can choose this folder in the installer), one folder to save my own files to and one folder where VB stores the user.config file.
Can something be done about this "mess" or is this just something I have to live with?
View 2 Replies
Apr 1, 2009
I want to write two nested loops and inside them "two if statements" when I write an Else statement which has a messagebox saying that ID is not found.. it repeated many times depending on the for loops. I only want to be displayed once !!! but when I wrote my code like this (using exit sub), the message appears when the condition is right and appears when the condition is wrong. I tried to move this statement somewhere else but still I have problems with it.
With EMPDataSet
For I = 0 To .Personal.Rows.Count - 1
For j = 0 To .Work.Rows.Count - 1
If EMP_CPR = .Personal.Rows(I).Item("CPR") Then
txtName.Text = .Personal.Rows(I).Item("Full_Name")
[Code] .....
View 8 Replies
Jan 13, 2011
I have a question about using nested IF statements in a SQL query. I have a select statement that calculates a semester grade -- Dim sqlStr As String = "SELECT 'XXX-XX-' + right(socSecNumber,4) As [Student SSN], Round((firstExam + secondExam +(2*finalExam))/4, 0) AS [Semester Average] FROM Grades that I am displaying the results in a datagridview. I can successfully display the masked social security number and the Semester Average but I also need to convert the Semester Average to a letter grade to display in a newly created column for Grade. Can this somehow be done with nested If or Case statements within the SQL statement or is there a way to pass the Semester Average information as a variable to a nested vb If statement? Basically, I am needing to know how to display the letter grade to the datagridview using this criteria:
[code]...
View 16 Replies
Jun 16, 2010
I'm sure I can work out several ways to do this but I wonder if anyone has a neat trick for creating nested folders.For example, if I have a string containing "c:userspauldocsmystuff" I want to create that same folder structure on another drive. I don't want to copy any files, just create the folder structure i.e. "k:userspauldocsmystuff"
View 2 Replies
Jul 20, 2010
which is more efficient?(Assume case statements, etc., cannot be used.)
If a Then
If x Then
ax()
ElseIf y Then
[code]....
View 4 Replies
Apr 18, 2012
I am writing an application that will be used to extract information from any one of three different database applications, depending on the option selected. I would also like it to be possible to run it against one of several environments (e.g. development, test or live).
I plan to hold the relevant logon details (in encrypted form, of course) in the app.config file, with the appropriate details selected depending on the environment and application. Rather than have each option hard-coded into a Select Case statement, I want to be able to nest the variables in the app.config. I had envisaged a section of the config file looking like this:
[Code]...
View 7 Replies
Apr 14, 2010
I'm working on a program and in it I need to store all combination's of the numbers 1,2,3,4. I would like each combination to be it's own array, and instead of creating 24 different arrays (there are 24 different combinations 1,2,3 and 4 can be arranged) I was wondering if it's possible to create a nested array like so:
[ [1,2,3,4], [1,2,4,3], [1,3,4,2], [1,3,2,4] .......]
That way, I'd be able to reference index 2 of the above array and have the array [1,3,4,2] returned.I looked into multidimensional arrays, but this would require me calling each index of the row and column.I also looked into making a Structure in which there was an array that could hold 4 numbers, but wasn't sure if going that method would be practical or not.
View 4 Replies
May 16, 2010
I have an arraylist of a "Doctor" class containing Firstname, Lastname,etc. Some elements in this arraylist may be duplicates of others. I am trying to iterate through the arraylist and search for duplicates. Once i find a duplicate i want BOTH duplicates put into another array and removed from the original array.
here is my function
Public Function createArrayOfDuplicatesAndRemove(ByVal st As ArrayList)
Dim duplicates As New ArrayList()
Dim i, j As Integer
[code]....
How could something be out of range if i start at the end and work to the front?
View 5 Replies
Aug 11, 2009
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 Replies