Declaring An Array In .net?
Apr 7, 2010
I have 12 checkboxes jan, feb, ..... dec i want to display the checked checkboxes into a file i know how to write in the file but the format of displaying checkboxes is as follows if i checked jan, feb,march and april then output is jan,feb,march,april here my problem is how to collect checked value in array , and how to put comma betweem them.
View 7 Replies
ADVERTISEMENT
Mar 12, 2010
What is the difference between using the 'array' class in VB and just declaring an array like normal. In other words, what is the difference between:
Dim numOfTicketsPerDay As Array
Dim intNumOfTicketsPerDay(6)
As Integer
Is there any preference of when one should be used over another?
View 2 Replies
Oct 13, 2010
When declaring a byte array, what is the difference between the following? Is there one, or are these just two different ways of going about the same thing?
View 2 Replies
Mar 10, 2011
I'm trying to return an array of strings from a function, and got surprised by an error.
I would have expected this to work, but it produces an error:
Public Function TestError() As String()
Return {"foo", "bar"}
End Function
[Code]....
I guess I'm unclear on the meaning of the {}'s - is there a way to implicitly return a string array without explicitly creating & initializing it?
View 3 Replies
Apr 26, 2010
I am new to VB.NET but used to write a lot of code in VB 6.
How do i declare a variable length array in VB.NET?
In VB6, i would just put:
Dim sArrayList() As String
But when I do that in VB.NET, it highlights my array name and says "unused local variable". What do I need to do to get it to work without an error?
View 2 Replies
Sep 21, 2010
I'm working on a reporting section of code for an inventory app I'm making for my office.I call a text file, read every line into an array then populate information pages with what has been pulled from the text file.For reporting, I want to read every text file in the directory, reading each one into a multidimensional array.Thus I can call and report on each item, i.e.ItemArray(i,2) would be all systems with Windows 2008 EE..I have code that lists all files in the desired directory and counts each file, so I eventually get counts of how deep I need the first level of the jagged array to be. but not until after code execution. Basically how can I write each array of data to the jagged array.[code]But I get a null reference exception. "Use the new keyword to create an object instance".
View 8 Replies
Aug 28, 2009
If I were to execute five different SQL-commands, wich of these way would be the best/most effecient?
Dim sql(4) As String
sql(0) = "SQL-string 1"
sql(1) = "SQL-string 2"
sql(2) = "SQL-string 3"
sql(3) = "SQL-string 4"
sql(4) = "SQL-string 5"
[Code]...
View 16 Replies
Jul 4, 2009
Is there a way in which I could declare an array of labels in VB 2008?
View 7 Replies
Apr 20, 2012
How can I convert the following code into VB.Net?
private const UInt32 temp = 0xE6359A60;
I tried the following but it doesn't work.
Public Const temp As System.UInt32 = 0xE6359A60
View 2 Replies
Apr 13, 2010
We have a great book written for Visual Basic 2005 that we type code that is prepared in advance. We are using Visual Basic Express 2008 and normally this works really great; type the code run the program and it works, however I am running into a snag.
The textbook shows the following code: IN THE(General) (Declarations)AREA we are told to type the following:
' Create a Graphic object to use with the game's bitmap
Dim myGraphicObject As Graphics = Me.CreateGraphics
' Create an empty Bitmap Object
[Code].....
is there a difference between VB 2005 and VB 2008 that would be causing the errors? or am I missing something subtle maybe mistyped?
View 3 Replies
Feb 22, 2011
Ok, basically i have 3 different classes: one is a NormalUser, one is a SuperUser, and one is an Administrator. I have on one of my form loads an if statement like this:
If frmLogin.lstCurrentUserData(frmLogin.lstCurrentUserData.Count - 1).Contains("Normal") Then
Dim player As New NormalUser
[Code]....
So based on an item in a list, i want to create a new instance of that class to be my player. now i know that code doesn't work, because the variable is only present within the if statement. my question is, how can i declare "player" as a new instance of the correct type, and still be able to access it in other subs?
View 10 Replies
Jun 18, 2010
In the middle of attaching a Google Custom Search Engine onto my page,I have a string which I would declare in C# as
String rxPattern = "<(?>"[^"]"|'[^']'|[^'">])*>";
How do I convert it to a string in VB?I mean store the same value into the string variable rxPattern using VB/VB.NET?
View 1 Replies
Jan 8, 2009
How would you declare constants from a .dll, so you can use it in your program.
View 2 Replies
Apr 26, 2011
Trying to declare some arrays. I haven't worked with them that I remember. I always took the long road, of declaring each and every variable, but would like to learn this method. The problem is I'm having trouble with the methods I'm finding on the net..[code]for some reason there is a squiggly under each MonsterName except in the declaration that says "declaration expected"
View 16 Replies
Apr 12, 2011
visual basic 2008 express
' the following lines declare the variables and constants
Dim intDiameter As Integer
Const dblPI As Double = 3.14159
Const dblAREA As Double = 140125
Dim intLabel As Integer
Private Sub PizaSliceCalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]...
I made a working program to calculate piza slices, i was told i needed to declare pi and the areas as constants. when i rewrote the program it no longer works. the result keeps coming back as 0.
View 8 Replies
Sep 2, 2009
I haven't check yet all the new features of ASP.NET 4.0 but I'm wondering if one of those features (VB syntax) is declaration of class properties oppose to C# in less code.[code]
View 4 Replies
Mar 2, 2012
I've got a problem in the display of controls on a form. The form controls are fine on my development system, but when installed on another machine, (same operating system, but evidently some other installed objects), the textbox controls in some of the forms have a black backcolor. Some of the tabs are pure white with the blacked out textboxes, some are the normal color. Some of the textboxes in the other sections are fine, some are not.
Is there any way that I can declare that all my controls are to be the 'standard' .NET Framework 4 variety?
View 6 Replies
Jul 26, 2010
I actually came from VB6 and starting to learn VB.NET. I saw this line of code which I cannot understand how it works nor how it goes.
Private MAX_VALUE As Integer = (1 << 14)
View 2 Replies
Dec 7, 2009
I am now facing the part II confusion with dll files. I would wanna load a custom built unmanaged dll that someone completely built, and load it within Visual Basic. I cannot reference it, because it doesn't seem to work. I wanna figure out how to use coding to load those dll's. Here is what I mean. If you have heard of irctunes. I can control itunes the way I want mostly using a dll. Here is the link to download the whole zip: URL] There is irctunes.dll which is unmanaged. I would wanna load it with Visual Basic. I cannot reference. There is an html file. It tells you the functions and parameters. I wanna access the functions that are within the dll file.
[Code]...
View 10 Replies
May 30, 2012
We can declare a byte variable like this, for hex '88'
Dim bytes = New Byte() { &H88 } My case, 88 is assigned to a variable, hexvalue
How to declare the byte with the variable hex value?
Dim bytes = New Byte() { &H & hexvalue }the above throws syntax error.
View 2 Replies
Feb 19, 2011
I'm trying out a program which I found on the net. Why is it necessary to put to curly braces at the end of the statement? It gives an error: "Byte has no constructors". Dim data As Byte() = New Byte(1023) {} I can't put the code like this either, it produces the error "byte cannot be a 1-dimensional array".
[Code]...
View 2 Replies
Apr 12, 2011
I've been testing the code below (vb 2010) and everything works except for the fact that I cannot get the statement "Dim dirName As String = Path.GetDirectoryName(Application.ExecutablePath)" to work. The dialog is "Path is not declared.it may be inaccessible due to protection level".As you may note I have it commented out below and went with the more explicit statement. Note that the code is from another author and I'd like to understand how to make this work as originally provided.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileName As String = "flatfile.txt"
'Dim dirName As String = Path.GetDirectoryName(Application.ExecutablePath)[code].....
View 4 Replies
Apr 21, 2009
I have an application that I need to declare a new reportdocument. I try to do the following statement: report = new auditReport and it tells me that the auditReport is not defined. Even though I added the report to the project. I tried to do it in another application and it works fine.What could be wrong with the application that doesn't find the report I added to it?
View 1 Replies
Mar 29, 2012
if this silly but I am trying to declare a string variable by the following line
[Code]...
View 2 Replies
Feb 8, 2010
I have declared this variable in a module : Public GenericForm As System.Windows.Forms.Form
and then through code I can asign to that variable a specific form .For example GenericForm = Form1. Then I can use that variable to handle that specific form , for example :
GenericForm.Show
My problem begins when I want to handle a control on that form , for example :
GenericForm.TextBox1.Text = "aaa"
This code creates an error reading :TextBox1 is not a member of System.Windows.Forms.Form.I have been using code like this in VB6 and was quite useful ,but now in VB .NET I cannot .You see I have many forms on which there are some text boxes with the same name,so I declare a generic variable as Form and accordingly insert the code the desired text box conform the form I wish each time . Can I do this in VB .NET too ?
View 23 Replies
Jan 13, 2011
I'm working on a simple BlackJack (player vs dealer) system, that I plan on making gradually more advanced. However, while everything works brilliant, I'm yet to find a logical solution to declaring an Ace as both 1 and 11.So my question is, how do I pull this off. Below is the "New Game" logic (code) so it should give you an idea of what I'm working with (note how player scores are added together, I'm sure it's easy enough to understand...).I'd like lblPlayersum to still be a usable integer, though I'll rework everything if noone has a logical solution.Just quickly note that the "Cards" array is purely used to coordinate images."CardsVal" coordinates that values within the deck. Arrays 48, 49, 50 and 51 are the aces. (Currently defaulted to 11).[code]
View 1 Replies
Oct 6, 2011
I have just been experimenting with nesting classes within a User class I had already created.
E.g.
Friend Class User
[Number of Properties...]
Friend Class Address
[code]....
I get the same error message!!! "Declaration expected". Also I notice the variable's name is not coming up in intellisense. I have not come across this before as declaring an using variables and objects has been straight forward up until now.
View 2 Replies
Feb 11, 2012
Having problem declaring constant on Visual Basic. rents is $200 per hour and is charge by minutes this is what I have so far.
const TOTAL_CHARGE_GROUP as Interger = 200 ©
View 8 Replies
Sep 29, 2011
The user clicks a button, a new form is generated where the user enters his/her password? How can I keep an in-memory copy of the username?
For instance in web forms, I can just use Session ("User"). How can I replicate this with winforms?
View 3 Replies
Jul 8, 2011
I have a form that I want to draw an image on.I also want this to be an animation so I can't use picturebox.However when I declare the graphics it gives me the error: "Type 'System.Drawing.Graphics' has no constructors"
:I have already import 'system.drawing:
Dim g As New Graphics() 'I get the error here
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
[code].....
View 7 Replies