VS 2008 Looping Through An Object?
Dec 15, 2009
I have been using the following code for quite some time to list the property values of an object:
Dim instance As New Configuration
Dim propValue As Object
For Each pi As System.Reflection.PropertyInfo In instance.GetType.GetProperties()
[Code].....
Works great but we've gotten alot of properties at this point and could use them in alphabetical order.
View 3 Replies
ADVERTISEMENT
Mar 15, 2012
I got two forms.
Form 1 I ask the user a number of guest
Form 2 I ask each guest their name, their age
I decide to make a loop throught form2 array base on the number of guest but then I got this error. NullReferenceException was unhandled.
Private Sub btnBook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBook.Click
iTest = CInt(txtChildren.Text)
Do Until (iCounter = iTest) And (bIsNextClicked = True)
PassengersDetails(iCounter).ShowDialog()
Loop
End Sub
View 5 Replies
Feb 25, 2012
The problem is as follows, a group of users (~50k) must be filtered from a DB, four fields for each user must be saved into a variable, then a second process will take each user and proceed to enable some licences into another system/platform. Both processes will be developed into the same application.
My first attempt was basically a query looping through the users but I wonder if thinking in objects is a better approach.
I was thinking in a structure inside an object to hold the 4 parameters, then pass each user object to the other object however considering the amount of data I'm not sure if this is fine.
View 1 Replies
Feb 10, 2012
I save the client data into an array list. How to find part of data(currentIP) inside the array list(clientList) with fast method? [code]
View 1 Replies
Feb 15, 2012
I have the following basic code to read a text file from a StreamReader:
Using sr As New StreamReader(FileData)
Dim line As String = String.Empty
Do
'Error occurs on the next line after looping
'past the *last* line in the file...sometimes
line = sr.ReadLine()
'Some code here to parse and process the line
Loop Until (line Is Nothing) OrElse (line = String.Empty)
End Using
I tried changing the Do Loop to Do While Not sr.EndOfStream I tried checking If sr.ReadLine IsNot Nothing and a few other things but I keep getting the Cannot access a disposed object. Object name: 'SslStream' error after all 105 lines have successfully been read and processed. This code has been working for a couple of years, but there seems to be some issue with certain files (recently) that is causing this problem.
I opened the file and I didn't see anything out of the ordinary. No extra blank lines, funny characters or anything of the like. Just a normal file with 105 properly formatted lines. So even know there is something about this file causing the error, I need to obviosly handle this programatically.
What can I do to prevent the sr.ReadLine() line of code from throwing that exception that I have not yet tried?UPDATE Upon reading the last line of the file, the 'EndOfStream' property on the StreamReader goes immdeatly to: EndOfStream: {"Cannot access a disposed object.Object name: 'SslStream'."} It never toggles to 'True'. This makes checking for this condition problematic.
I think I have figured out why this issue only occurs sometimes: if I add in a blank line to the file at the end, none of this ever occurs. It is only when the last line of the file contains data. Still, I should be able to handle this programatically. Telling the vendor supplying the file to always add a blank line at the end should not be the solution.
View 2 Replies
Oct 15, 2011
Mine is a windows app. containing forms named BOM nd BOMSelected..There is datagridview in BOM which contains checkbox column.. When the user selects checkbox, the selected rows should be seen in the datagridview of other form, SelectedBom..
[Code]...
View 39 Replies
Apr 20, 2009
looping through check boxes.. checkbox1, checkbox2, checkbox3...... Error in the code ocheck = "CheckBox" & Str(t) as "Run time errors may occur when converting 'string' to 'Microsoft.office.interop.word.checkbox'." Dim No_Checkboxes As Integer, ocheck As CheckBox
[Code]...
View 7 Replies
Sep 8, 2009
I would like to know how to loop with textboxs. For example. I would set the text to "Hello" And the loop will send this...
-"Hello1"
-"Hello2"
-"Hello3"
I have tried many looping techniques but they all used listboxs and even modifying them I could not get it to work correctly.
View 3 Replies
Dec 14, 2009
I have this Visual Basic class I'm taking online. At this point in the section all I'm supposed to know about are Do, Do While, Do Until, Exit Do, Continue Do, and For Next loops. So try not to go off in a fancy super-coder direction. And everything is (preferably) made through Console Applications on VBE 2008
Problem 1:
Write a program that evaluates the factorials of the integers from 1 to 10 using an appropriate data type. (factorials are... factorial of 1 is 1, factorial of 5 is 120, or 1*2*3*4*5=120)
Problem 2:
Make a diamond - 1 asterisk at the top, 9 asterisks at it's widest - using only nested For...Next statements to print the asterisks AND spaces, minimizing use of output statements.
View 4 Replies
Mar 29, 2009
[code]I am facing difficulty in coding when intRow loop for the 2nd round. Error message "There is already an open DataReader associated with this Command which must be closed " appear in the above red highlight vb.net code.
View 6 Replies
Jul 12, 2010
I have some code that should update my listbox with files in a directory i have this code put in a timer:
[Code]...
View 10 Replies
Apr 21, 2009
Have this Uni question; which after 20 minutes of frustration I'm sending it to the brain trust (you might be interested).Write a program that, when a button is pressed, checks the contents of a textbox. If the textbox does not contain a number, the program informs the user of this and does nothing more. Once a number has been entered, the program will do something trivial such as displaying double the number in a message box.Notice that this can be done without explicit looping,even though the user might repeatedly enter non-numbers. Because it is an event-driven program, each iteration is started when the user clicks the button. The looping is driven by the user, not by a looping statement.
View 5 Replies
Jan 11, 2011
Im trying to loop through all rows in a datagrid and enter a calculation in the field in the next column (first column is already populated with appliance names). The code below works but only on the first row. Can someone be good enough to point out my error? For Each row As DataGridViewRow In DataGridView1.Rows
If DataGridView1.Rows(s).Cells(0).Value = "" Then
DataGridView1.Rows(s).Cells(1).Value = "0"
Else
DataGridView1.Rows(s).Cells(1).Value = dtDLopt.Compute("SUM(Measurement)", "Appliance = '" & DataGridView1.Rows(s).Cells(0).Value & "'")
End If
Next row
View 3 Replies
Jul 2, 2010
I'm using this code to get the preview window
Dim iHeight As Integer = picCapture.Height
Dim iWidth As Integer = picCapture.Width
'
' Open Preview window in picturebox
[Code]....
As you can see, I have 2 sources. Would it be possible to not show the preview window, but instead loop through all the sources?
That would be in a timer, so like each 10 seconds a pictures is made from each source.
View 1 Replies
Feb 11, 2012
i have a winform and i have about 30 labels and 30 picture boxes on it. What i would like to do is fill each label and picturebox with a value and image from a backend database. I could have easily done this in vb6 using control struture , for eg.
for x = 1 to 30
picturebox(x).image = value from database
label(x).caption = value from database
[code]....
View 3 Replies
Feb 21, 2010
I have a number of textboxes in my program, and a few other controls with text in them.I want to loop through a select number of textboxes (1-10 in this case, for testing), and output their combined data into a string.Here is what I created, with the help of someone on this forum earlier.[code].....
View 4 Replies
Jan 3, 2010
I have my regex setup, which works prefectly:
vb.net
Dim testStr As String = "<option value=""18621335"">graham23s</option>"
Dim rx As New Regex("<option value=""(d+)"">(.+?)</option>")
[code]....
When i put it into my own application i have done:
vb.net
Dim stringSource As New Regex("<optionvalue=""(d+)"">(.+?)</option>", RegexOptions.IgnoreCase Or RegexOptions.Singleline)
Dim stringMatches As MatchCollection = stringSource.Matches(stringCle
[code]....
what i am having trouble with is getting the values while in the foreach loop.
View 3 Replies
Oct 6, 2010
i have this piece of
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFileSize As String = ""
Dim di As New IO.DirectoryInfo("C:")
[code]....
and it works just fine. However, saying that, i need to find a way to loop through ALL the directory's on the "c" drive and not just the main folder.
View 5 Replies
Jul 3, 2011
I'd like to go through all the items of a ListView control in order to ... well execute some code. I suppose I have to use the "For i=1 to ..." statement , but I am not familiar at all with this control. As I said , I'd like to check all of the items (the elements in the first column) and for each of them that has "Yes" on the third column , I would like to run the rest of the code .
View 9 Replies
Jul 29, 2010
I am looping through all controls on my form and for all checkboxes, I want to see if they are checked. I cannot get the Checked property when doing this. Am I doing something wrong?
[code]...
View 2 Replies
Sep 12, 2009
Ive been trying to work with looping code and get messeges like this.
[Code]...
But that is not important this moment... How would I set a code too use the progress bar? So As it loops at a certain rate {Lets say 1000 (1 sec)} It would show the progress. Currently using it to 1 - 50. (Note: The rate is not important as I know how to set that) EDITEDITEDIT: Thanks for the info so far, But regarding my other thread about hotkeys that I marked "Resolved"
[Code]...
View 5 Replies
Oct 29, 2009
The code below shows me (I think) that the "for each" loop is about 10% faster than the "i to n" loop, but the "for each" loop creates 567k in new memory? Is this right? Which way is generally most efficient with regards to speed and memory usage? If you want to run this code in VB just add a button and 2 labels to a form.
[Code]...
View 1 Replies
Jul 26, 2009
I was wondering how i can loop through a combo boxes items display item field - and return the value for each - i want this to be generic regardless of the combo boxes data source - or if the combo box has been populated with a string list / class etc
View 3 Replies
Feb 18, 2011
I have code to automize the creation of medical record charts in a data tree structure. I need to loop through a basic .txt to get relevant current case numbers and automate their chart creation structure. hat's wrong here... Msgbox(s) is returning my file name - not the first line in the file.
HTML
Dim myRootpath As String = "\backupcenterPDF_Archives$MedRecords"
Dim myTemplatePath As String = "\rbase$EMRTemplates"
[code].....
View 5 Replies
Mar 14, 2010
The issue is when I try to add a new item to the ArrayList with the following code, it gives me an error:
vb Private Sub btnLabelAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLabelAdd.Click
Dim result As String = InputBox("New Filter Label:", "Label List")
[CODE]................
Object reference not set to an instance of an object.
I'm not really sure what I'm supposed to be doing with this. It's a new setting I just added and it's empty, so I'm not sure if that has anything to do with it or not. Anyone know what's going on and what needs to be done to get it to accept a value and not want to be "initialized"?
View 9 Replies
Oct 23, 2009
I have recently gotten my hands on a free, open-source IMAP connection API.So far, I have been successful in creating a connection to one of my accounts.Where I'm getting stuck is retrieving folders and/or emails from those folders.Does there happen to be anyone here that is familiar with this API, or even Gmail (particularly the folder structure for IMAP)?
If not, here is a link to the DLL that is listed on sourceforge and the company's website that created it (if you feel like testing):
Koolwired
Sourceforge - Koolwired API
I have created a test account so feel free to use the code below without worrying about username/password issues; I'll just delete it when I'm done with it.Here is the code I have made so far for making a connection:
Dim gSession As New Koolwired.Imap.ImapConnect("imap.gmail.com", 993, True)
Dim gAuthenticate As New Koolwired.Imap.ImapAuthenticate(gSession, "imap_test@serysoft.com", "imap_test")
Try
[code]....
When I run that code, I get an error that states:System.NullReferenceException: Object reference not sent to an instance of an object. (The bold line in the above code).
Now, I'm not sure exactly what that means. Does that mean it tried to access the server and "INBOX" doesn't exist so it gets returned a NULL value? Or is it possibly the coding itself?Maybe the Gmail folder system is weird due to the fact they use labels (even though from what I have read online, the labels act as the folders in the IMAP system).
View 11 Replies
Sep 15, 2010
What is the problem in below code.
d Public Sub filltextbox(ByVal dlist As String) Dim tb As TextBox = CType(Page.FindControl(dlist), TextBox) tb.Text = "hello" End Sub
Error : Object reference not set to an instance of an object.
View 14 Replies
Apr 26, 2011
look after the error i'm having.
module1.vb
Imports System.Data.SqlClient
Module dbconn
[code]....
View 5 Replies
Dec 5, 2010
I create one function to run any select query. and return the OdbcDataReader type.But some time if there is no data it through error : Object reference not set to an instance of an object I need to know how i can control if there is no data.
Public Function Select_From_AnyTable(ByVal sqls As String, ByVal ConStr As String) Dim conn As OdbcConnection conn = New OdbcConnection(ConStr) Dim cmd As OdbcCommand = conn.CreateCommand() conn.Open() cmd.CommandText = sqls Dim reader As OdbcDataReader = cmd.ExecuteReader While reader.Read() Return reader End While conn.Close() End Function Dim ei As OdbcDataReader = Select_From_AnyTable("SELECT loginname from usertable limit 1", conStr) msgbox(ei.item("loginname "))
If there is data it work well but if no record found it through the error.
View 3 Replies
Aug 31, 2009
Is there a way to convert a DataGridViewRow object to a DataRow object?
View 2 Replies