I have an array x in size of objects (between 1 and 100) and I want to increase the size to 101 ... I've resized the array and that adds the objects but unfortunatly (not suprising) the added items have not been initialised, do I've reverted to using a do while loop and adding the elements indiviually, but looking at the code around it where addrange is used extensivily, I was just wondering if that was a neat vb.net way of doing the same thing
Bit of a learning question, just looking for neat ways to do the same thing
I've come up with the following and it's partly working.
Public serial1, serial2, serial3, serial4, serial5 As SerialPort Public serialports() As Object = New Object() {serial1, serial2, serial3, serial4, serial5} dComPort = "COM4"[code]....
The above code works fine! But im having trouble trying to now retreive whats stored in the array.In the above example, an entry will be stored in serialports(4), all other array elements will be blank.If I do this it works.
MsgBox(serialports(4).PortName) ' this retuns the value COM4
But I'd like to loop though all array elements and print out ALL the PortNames, The below code doesnt work, I get an error Object variable or With block variable not set.
For i = 0 To serialports.Length - 1 MsgBox(serialports(i).portname) Next
I need to read an xml document from a database record into an XDocument object in order for it to be deserialized. So that the deserialization will work, I need to apply a specific namespace to each of the level 1 elements. So XML looks a bit like this:
[Code]...
How do I prevent the blank/empty namespace being added to each child element of the element to which the required namespace has been applied?
I am just starting VB at 60 years old and with no programming experience and nobody to ask for help...except here, of course. So needless to say I am hitting brickwalls. I am using "Murach's Visual Basic 2008" and it seems to be a good book. This is what I am up to I have to declare an array with 5 elements with an index. I think that part is OK. Then add code that adds each element to the next one every time a user clicks a button. I have had many tries but the best I can get is just the grand total of the elements. Here is the code I came up with:-
[Code]...
Is anyone able to show me how the button click would reveal a progressive total of the elements each time a user clicked on it? It would be good if the book came with answers or had a forum for their readers.
I have a data table in a loop that adds rows on each loop. During the loop i collect an array of unknown size. At the end of the loop i want to add a new row to the datatable with eachelement of the array as a field.[code]I could hard code this if i knew how many item would be in the array but i dont.Is there any way i can loop through the array and append the value to a row?
I have a form that I need to show "nonmodal" while I do some work, the form displays a label that outputs strings captured from a cmd window. So I am doing it like this Dim f As New AutoRDP() f.Show() f.doit() f.Close() Private Sub lockprompt_Load(ByVal sender As System.Object, [Code] ...... The problem I have is I can load the form correctly.. all the elements loads up blank. But if I use showdialogue() it loads correctly, but I cant return to do my work..
I'm trying to sort an array based on a structure but whenever I do this, it basically erases all the data in the entire array.I have verified that the array is populated correctly, it is when using array.sort that everything returns blank.
Assume I have an array myArray1 = { A, B, C, D, E, F, ., T}I have another that contains a subset of the elements of myArray1 but where the order may vary
I feel quite silly asking this, but I couldn't find a definite answer anywhere. in vb.net, how are the array elements defined (if they are defined) for, for example:
Dim myarray(5) as int
does, at this point in time, myarray(3) for example have a defined value? If so, what is it?
I have a one-dimensional array that has one number per element. I also have a variable number, var. I need to take the number of elements from the first array that equals the var and put it into a second array with commas between the numbers. I would also like to have a title element in the second array. [Code]
I've inherited a form that has a DataGridView that is bound to a dataadapter and it is connected to a binding source. Within the DataGridView is a combo box that is bound to its own bindingsource which basically just calls a stored proc to bring back the possible values for the dropdown combo control
With a blank new row and sometimes even with an existing row, this value for the combo box can be NULL which is a legitimate value for it if no value selected. Problem is everything is so tightly bound if the user mistakinly clicks the dropdown then a value is populated and there's no way to get back to NULL
I've tried to catch the mousecelldown event and others to try to catch this before a value is selected but the Cancel=True doesn't work - I can catch the event but don't know how to return the cell to unclicked or reset it to NULL or pre selected value if NULL I know how to at a new row with the datatable and then set the combo datasource to it and I have my null blank value but with a tightly bound control how do I add this row?
I'm trying add a new row to my databaseTo add a new record a pop up form opens (form2) with a textbox for the user to input their name, they then click the save button and the popup form closes and the main form (form1) is still showing and the added row seems to updated in combobox although it is blank!.This causes a new blank row to be added to the database - the data in the textbox is never saved to the database
vb Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
I've been having fun with the xmldocument class recently but am struggling with namespaces. I've been trying (with some success) to merge parts of one XML file into another. The problem has been that one of them utilises a namespace on one of the interior nodes and therefore my xpath queries where failing when I tried to create a nodelist. This I fixed (after reading some great examples here) by adding a namespace manager and changing my query accordingly.
Everything looked fine initially and I appeared to end up with the desired effect, but the XML file that was created was failing in the target application. What I didn't realise at first (due to the length of the xml node values being wider than my screen!!) was that when I imported the nodes from one file to another, a blank names space was being added to the end of each node (xmlns="")
' load the xml template from the project resources Dim fdf As New XmlDocument fdf.LoadXml(My.Resources.fdf_template)
I am trying to add (Push) whatever the user enters in (MyStack) into 5 different labels that should show the (UserResponse). The problem is I don't know how to display each element in a different label. For example:
- The first element that the user enters (UserResponse) should be in Label1
- The second element that the user enters (UserResponse) should be in Label2 etc.... up to label5.
Also, when I press (Pop) the elements should disappear (Last in first out).
Public Class Form1 Private MyStack As New Stack(4) Private Sub ButtonPush_Click(sender As System.Object, e As System.EventArgs) Handles ButtonPush.Click
When I load a page into the web-browser control I have a text box and a button to insert more html and various other, but when I do so it redirects to about:blank. How do I stop this from happening. I cannot find anything that would hint me to fixing this problem anywhere Also this is how I add text to the page:
So I have a dropdown setup on the page called ddlVehicleType that is populated from a store. This method gets called when another dropdown is changed, and it's supposed to remove all items from the aforementioned store, re-add them as needed, and then populate the dropdown with the new values.
It's doing everything it's supposed to EXCEPT clearing the store before it re-adds the values, so the result is, when I switch, I'm getting what it used to be PLUS the new values that should be in there by themselves.[code]...
I am trying (Push)add data into my stack (length of five) and (Pop)delete from the end of my stack.
I need to know how can:
- Add the elements to the stack with keeping track of adding and deleting from it (adding an element will increment until 5 and deleting would decrement until the stack is empty).
Private Sub Button1Push_Click(sender As System.Object, e As System.EventArgs) Handles Button1Push.Click Dim Stack(4) As String
I am trying to create a array and then add elements to it based on some conditions and then add the elements in the array and display it...
but i am getting a larger number that expected..
this is my code
Dim IBNRTotal as decimal dim element as integer dim totals(6) as decimal -- create a array3
[Code]....
i know the amt value correct cause in return amt.. i am seeing the right value but somehow when it goes to the array and when i add the whole thing it doesnt seems right...
Now I'm VERY new at the reading in a text file and storing into arrays thing and tried for hours last night to figure this out, googling and every possible way of writing the code. However, I don't know what to try next and I'm getting more confused by the minute. I have a text file which I load into my program. This data is stored into 6 arrays, each of which has data that comes from either a combobox, date or text field. What I'm trying to do is to find the count of items in each index of the array.
In this case I'm trying to create a number analysis app. I'm required to declare an array and get the data for the array using ten text boxes. Why, because my instructor said so.
My problem is my event is returning zero. Therefore I believe my code is somehow flawed.
My approach is to create functions that calculate the required metrics. I have only tried to code one function to date. If I can get help making one function work, I will be able to do the others .
Public Class Form1 Dim decScore0, decScore1, decScore2, decScore3, decScore4 As Decimal Dim decScore5, decScore6, decScore7, decScore8, decScore9 As Decimal
I have a class I am working on for a program I am writing while I am stuck at hospital 3x a week and was wondering. If my class has a Reset function that sets the count variable to 0, can I then say that the Data array is equal to "nothing" and wipe all the data that was in it?
Below is the class structure so far: Private Count As Integer = 0 Private Data() As Integer Public Sub Add(ByVal value As Integer) Count = Count + 1 [Code] .....
For example, I have an integer array called sec1() that has 71 elements.
I tried:
vb sec1(1 - 71) += 1 But when I run the program, it gives me an error. Not a red-underline error, some other error that doesn't stop the program from compiling but stops it from running. Is there a way for me to modify all of the element of my array at once? just out of curiosity will the same method work for string arrays?
I am trying to teach myself programming and I am on the subject of arrays. I want to create a simple program that asks the user to input 5 numbers and then outputs those numbers to the user. The program is a console application and I'm using Visual Basic 2005. My code is as follows: