VB 2008 Class Array Declaration?
Jul 19, 2010How can i declare a public array of class instances, in Visual Basic 2008 express?
View 7 RepliesHow can i declare a public array of class instances, in Visual Basic 2008 express?
View 7 RepliesI got problem regarding declaration of dynamic runtime array declaration Here is my code
[Code]...
I have two classes; one is a data class which contains routines to handle data and the second is a utility class which contains useful routines which can be used again and again. I have come across a problem. Some of my routines in the utility class use routines in my data class and now I want to use some of my utility routines in my data class. I tried this in a service and the service just would not start. After commenting out code I realised it was because I was making a declaration in the utility class for the data class and in the data class making a declaration of the utility class.
I understand that this is now causing looping but is there a different way to do what I want. If not I would need to have two copies of routines in both classes.
I am trying to create an list or an array of a class.Here is my "Ingredient" class that I am trying to create a list of:[code]In my "recipe" class, I am want to create a list (or array) and I am drawing a big blank on how to do it. Can anyone point me in the right direction?
View 2 RepliesQuestion: How to shorten this array creation ? I need to create an array of type ReportingService2005_WebService.Property with one property.
Something like:
Dim PropertyArray() as new ReportingService2005_WebService.Property(1)
I have to do this:
Dim PropertyArray As ReportingService2005_WebService.Property() = New ReportingService2005_WebService.Property(0) {}
PropertyArray(0) = New ReportingService2005_WebService.Property
[Code].....
For some reason when i declare an array and set it to a certain amount of elements then under it specify the elements it works in VB 2005 but when i do it in VB 2008 it get : "declaration expected " and i get words underlined.
Public Class Form1
Dim words(20) As String
words(1)="Computer"
End Class
Let me know how to do this in 2008!
In the code below, when I use the same interface with O in the Class declaration line and the Inherits line, I then get a compiler error when I access the interfaces Year member in both the properties. It says " 'Year' is not a member of 'IRegionYear'." I get the same thing if I use the same class with each Of.
I don't get this error when the interface or class entered for both Of clauses are different.
Interface IRegionYear
ReadOnly Property Year() As Integer
End Interface
MustInherit Class RegionYears(Of IRegionYear)
[Code] ......
I'm a newbie to VB, and I am having difficulty understanding what the following (legacy code) class declaration actually means:
Public MustInherit Class ModelBase(Of T As {ModelBase(Of T, TIdType), New}, TIdType)
There is also a related ModelBaseCollection:
Public MustInherit Class ModelBaseCollection(Of TCollection As {ModelBaseCollection(Of TCollection, TModel, TIdType), New}, TModel As {ModelBase(Of TModel, TIdType), New}, TIdType)
Inherits Collection(Of TModel)
I have difficulty understanding the need for the ModelBaseCollection class as the ModelBase class is a generic type.
I want to convert this C# two dimensional array declaration: [code]But I got error message, "array initializer has too many dimensions", and there is a green jagged line below {1,2,3} in two dimensional array VB.net declaration.
View 9 RepliesConvert 2 dimensional array declaration from C#
View 1 RepliesI have been searching for memory leaks in my application and come down to this weirdness. I have a class which implements IDisposable and one single event in it as shown below:[code]
View 1 RepliesThis is hopefully a softball syntax question: I need to call a method with an empty Object array for evaluation and set initial state. In C# I would just do this:
func(new Object[]{});
In VB.NET I am forced to do this:
Dim ctrls() As Control = {}
func(ctrls)
Is there a way to shorthand the call in VB.NET and have everything happen in one line of code?
I am using VB.NET 2003 and declared a string array as follows:
Dim Level(1500) As String
The program stops at 1000 when it is executing. Is there a maximum limit? Should compile or ling different?
I have been working on an activeX control which works on serial port communication. Now I have completed the project and created its setup.exe using Visual studio 6 -> Tools -> Package and Deployment Wizard. Then I installed the control in another PC and in a new project included the control using project -> components. But when I click on the control in the toolbox and then include on the form it gives the following error : delete current link ? and on clicking OK, nothing happens. I tried searching a lot on google but didnt find anything. Another problem is that I have created a string array as a global array which can be accessed by all the methods.I am able to include the same activex control in my own pc when I have created the project. Here it works fine, I am able to access all the methods that I coded in the control, but the String array mentioned above can be accessed in other project. I tried writing Public before the array declaration but it give me the compile error : "Constants. fixed length strings, arrays, user defined types and Declare statements not allowed as Public members of object module." [code]
View 1 RepliesI have an array of pictureboxes in my form and i want to use the picture boxes in a class. I know you have to use a constructor for this but i'm not sure how to code it exactly. I have tried many things but it just does'nt want to work..here is the code of my array in the form and the constructor
Dim Deler As dealer Protected cardPlace_array() As PictureBox = {picDKaart1, picDKaart2, picDKaart3, picDKaart4, picDKaart5, picDKaart6, picDKaart7, _ picUKaart1, picUKaart2, picUKaart3, picUKaart4, picUKaart5, picDKaart6, picUKaart7}
[Code]...
I declared made an array of my class like this
Dim
myClass(3) As Class1
Now when I try to enter data like this:
myClass(0).s = ("Test")
I get an error "Object reference not set to an instance of an object."
In order to re-sort the data received in USB easier, I send the data array received in USB (declared as Byte) to a temporary array (declared as SByte) to re-sort. I declared the temporary array as SByte just for easy sorting. After I compiled, an error message came up "make sure not divided by zero". I tried to use convert.SByte but still didn't help. Is it not allowed to send data to an array with different data type declaration?
View 1 RepliesI have several classes that use a bunch of strings for directories, arguments, etc.
At the moment, they're all just declared globally within the class like so:
VB.NET
Private str1 As String = "path"
Private str2 As String = "path2"
Private str3 As String = "arg"
To me, that looks awful and doesn't seem like the proper way of doing things. So, I was thinking, should I make a property for each string and then use a constructor to initialize them?
Would that make a difference at all? Is that the proper way of doing things?Also, some strings are used in a ton of different places and they're basically just being copied from one class and pasted into another. So, do you think I should do what I suggested above, but with a class whose sole purpose is to house those strings so that the code isn't duplicated a million times everywhere? Would that be the most efficient way of doing things?
[Code]...
i'm making practice with GDI+ and i need an help with the creation of a new brush:i have two if condition and for each if i need to define a new kind of brush(Solid,HatchBrush)[code]but when i try to apply to a graphic object the brush i have an error: "nBrush not declared"..there is a way to declare a brush object without properties and then tell if it must be solid or hatch? there is another way to solve this problem?
View 4 RepliesAPI is written in C++
typedef unsigned short MFSTATUS; // known as a WORD - 16 bits for sure
MIFAREAPI_API MFSTATUS MIFAREAPICC MF_ReadCardBlock( DWORD dwBlkAdr, DWORD dwRdrKey, DWORD dwKeyAB, DWORD dwRspBufSz, BYTE *pRspBuf );
HOW DO I TRANSLATE IT TO VB?
Declare Function MF_ReadCard Lib "MifareAPI.dll" Alias "MF_ReadCardBlock" (ByVal BlkAdr As Long, ByVal RdrKey As Long, ByVal KeyAB As Long, ByVal BuffSize As Long, ByRef buffer As Byte()) As Short
I am new in this forum, also new in VB.Net I need to create a public class for insert and delete data to database Public Class My_DBFunctions
[Code]...
In my VbNET2008 window application I include a EXCEL Spreadsheet and it generate 2 error messages when I declared the WorkBook and Worksheet.
Here are the error message:
Error 3 Type 'objExcel.Workbook' is not defined.
Error 4 Type 'objExcel.Worksheet' is not defined.
Here are the coding that generated the error messages:Imports Microsoft.Office.Interop.Excel
Dim objExcel As Microsoft.Office.Interop.Excel.Application = CType(CreateObject("Excel.application"),Microsoft.Office.Interop.Excel.Application)
Dim objWorkBook As objExcel.Workbook = CType(objExcel.Workbooks.Add, objExcel.Workbook)
Dim objWorksheet As objExcel.Worksheet = CType(objExcel.Worksheets(1), objExcel.Worksheet)
I'm designing a small GUI Windows program that allow staff at a cinema to reserve seats for customers. There will be a total of 60 seats in the cinema. I have two classes in my program:-
1.) MainForm.vb - used for I/O actions and user interaction
2.) SeatManager.vb - used to hold and handle the background methods and functions that make the program work
Here is the code for my MainForm.vb class thusfar:-
Public Class MainForm
Private Const m_totalNumberOfSeats As Integer = 60
Private m_seatManager As SeatManager
[Code]....
Basically, when the program opens, the lstReservations list in the MainForm class will be populated with a total of 60 (m_totalNumberOfSeats) entries to represent 60 seats. Each of these seats will contain the index number from the array m_nameList; this index number (+1) will represent the seat number and then in the lstReservations list, after the seat number, I'd like it to contain the respective entry from the m_nameList array. As all entries will be held in RAM, when the GUI is opened, all m_nameList array entries will be empty. As the user uses the program, they can highlight a row in the lstReservations list and then use the GUI textboxes to enter the customer's name which will then be populated into the respective array entry.
how to, when the GUI opens, ensure that the lstReservations list takes all of the blank entries from the m_nameList array and from there, I can highlight a row to carry out further methods on?
I want to reading in a excel file and extract the sCodenumber sDescription ans the sStatus and store them in a array : StatusComposeArray(5200) As MyCompose. After this I need this array for comparing outside this class. But as can you see the array is defined inside the sub: ReadingIn_ExcelFilesCompose [Code]
View 2 RepliesA c# class's single dimension byte array contains socket level instrument sensor data as per:
public static byte[] frameData
It's been a LONG time since I messed with VB, and I'm messing around with VB 2008 now.I'm trying to make a custom class with three variables,
ID (String)
Title (String)
Comments (Array of String)
[code]......
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?
If I make the following array in a push button event and I want to put those array variables in a class array. How do I do that? I am just beginning to learn about classes in vb.net but I am having problems using classes and arrays.Is there any good tutorials on that subject.
[Code]...
I'm designing a small GUI Windows program that allow staff at a cinema to reserve seats for customers. There will be a total of 60 seats in the cinema. I have two classes in my program:-
1.) MainForm.vb - used for I/O actions and user interaction
2.) SeatManager.vb - used to hold and handle the background methods and functions that make the program work Here is the code for my MainForm.vb class thusfar:-
[Code]...
I have main class of Races with mulitple properties. One of those properties has been defined as another class Runners.
So I have a race with multiple runners and when I try to update the data i get an instantiation error.
For the life of me I can't get it to work.
This is what I am trying to do...
In the clsRace class I have defined :
PublicProperty clsRunner(ByVal index AsLong) As clsRunner
Get
[Code].....