How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like
{{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if I
know how to create this array or whatever else method is needed.
--
Anil Gupte www.keeninc.net www.icinema.com 12 6427
Public struct Storage
Dim a as Integer
Dim b as String
End Struct
Dim info() as Storage
Anil Gupte wrote:
How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like
{{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if I
know how to create this array or whatever else method is needed.
Sorry, it must be:
Public structure Storage
Dim a As Integer
Dim b As String
End Structure
Dim Info() as storage
Theo Verweij wrote:
Public struct Storage
Dim a as Integer
Dim b as String
End Struct
Dim info() as Storage
Anil Gupte wrote:
>How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like {{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if I know how to create this array or whatever else method is needed.
In that case, I may as well as create a class, right? I understand
Structures are "passe" in OOP?
Only problem is, creating a class that is an array sounds daunting....
--
Anil Gupte www.keeninc.net www.icinema.com
"Theo Verweij" <tv******@xs4all.nlwrote in message
news:OT****************@TK2MSFTNGP04.phx.gbl...
Sorry, it must be:
Public structure Storage
Dim a As Integer
Dim b As String
End Structure
Dim Info() as storage
Theo Verweij wrote:
>Public struct Storage Dim a as Integer Dim b as String End Struct
Dim info() as Storage
Anil Gupte wrote:
>>How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like {{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if I know how to create this array or whatever else method is needed.
"Anil Gupte" <an*******@icinema.comschrieb:
How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like
{{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if
I know how to create this array or whatever else method is needed.
Check out the chapter about "jagged arrays" in the documentation.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Anil,
Structures are "passe" in OOP?
No! Why would you think that?
Structures are used when you need to define "Value Types" within .NET http://msdn.microsoft.com/library/de...Guidelines.asp
Basically when you need a type that:
- acts like primitive types (acts like an integer)
- Have an instance size under 16 bytes
- Are immutable
- Value semantics are desirable.
Although Classes are more commonly used in .NET, Structures still offer all
the major tenets of OO (Encapsulation, Abstraction, Polymorphism)...
Considering there is significantly more to inheritance then the common
Implementation Inheritance found with Classes...
Only problem is, creating a class that is an array sounds daunting....
You wouldn't create a class that is an array, you would create an array of a
specific type. That specific type can be either a reference type (Class) or
a value type (Structure)
In the example you gave, an array of Structures might be easier to use then
an array of Classes...
--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Anil Gupte" <an*******@icinema.comwrote in message
news:em****************@TK2MSFTNGP05.phx.gbl...
In that case, I may as well as create a class, right? I understand
Structures are "passe" in OOP?
Only problem is, creating a class that is an array sounds daunting....
--
Anil Gupte www.keeninc.net www.icinema.com
"Theo Verweij" <tv******@xs4all.nlwrote in message
news:OT****************@TK2MSFTNGP04.phx.gbl...
>Sorry, it must be:
Public structure Storage Dim a As Integer Dim b As String End Structure
Dim Info() as storage
Theo Verweij wrote:
>>Public struct Storage Dim a as Integer Dim b as String End Struct
Dim info() as Storage
Anil Gupte wrote: How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like {{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if I know how to create this array or whatever else method is needed.
To provide a custom sorting algorithm, implement the IComparable interface
in the class, and then craft the CompareTo override. If you look up "IComparable
interface, about IComparable interface" in the on-line help, it will provide
an example.
-----
Tim Patrick
Start-to-Finish Visual Basic 2005
How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like
{{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that
if I know how to create this array or whatever else method is needed.
Thanx yes,that does help. I have read about Enums, now I will go read up on
structures. I was given the impression by some programmer that real OOP
does not include Structs.
Anyway thanx,
--
Anil Gupte www.keeninc.net www.icinema.com
"Jay B. Harlow" <Ja************@tsbradley.netwrote in message
news:8B**********************************@microsof t.com...
Anil,
>Structures are "passe" in OOP?
No! Why would you think that?
Structures are used when you need to define "Value Types" within .NET
http://msdn.microsoft.com/library/de...Guidelines.asp
Basically when you need a type that:
- acts like primitive types (acts like an integer)
- Have an instance size under 16 bytes
- Are immutable
- Value semantics are desirable.
Although Classes are more commonly used in .NET, Structures still offer
all the major tenets of OO (Encapsulation, Abstraction, Polymorphism)...
Considering there is significantly more to inheritance then the common
Implementation Inheritance found with Classes...
>Only problem is, creating a class that is an array sounds daunting....
You wouldn't create a class that is an array, you would create an array of
a specific type. That specific type can be either a reference type (Class)
or a value type (Structure)
In the example you gave, an array of Structures might be easier to use
then an array of Classes...
--
Hope this helps
Jay B. Harlow
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Anil Gupte" <an*******@icinema.comwrote in message
news:em****************@TK2MSFTNGP05.phx.gbl...
>In that case, I may as well as create a class, right? I understand Structures are "passe" in OOP?
Only problem is, creating a class that is an array sounds daunting....
-- Anil Gupte www.keeninc.net www.icinema.com
"Theo Verweij" <tv******@xs4all.nlwrote in message news:OT****************@TK2MSFTNGP04.phx.gbl...
>>Sorry, it must be:
Public structure Storage Dim a As Integer Dim b As String End Structure
Dim Info() as storage
Theo Verweij wrote: Public struct Storage Dim a as Integer Dim b as String End Struct
Dim info() as Storage
Anil Gupte wrote: How can I dimension an array like this: > dim info(a as integer, b as string) so I can store somthing like {{"John", 10}{"Dan", 20}{"Jane", 30}} > I want to be able to sort this array too, but I think I can swing that if I know how to create this array or whatever else method is needed.
I think jagged arrays are only avaialble in C#, not VB. I looked in the
dynamc help and also in the books for VB that I have, but there is no
mention of it.
Thanx,
--
Anil Gupte www.keeninc.net www.icinema.com
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:O4****************@TK2MSFTNGP03.phx.gbl...
"Anil Gupte" <an*******@icinema.comschrieb:
>How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like {{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if I know how to create this array or whatever else method is needed.
Check out the chapter about "jagged arrays" in the documentation.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Thanx!
BTW, What is Start-to-Finish Visual Basic 2005?
--
Anil Gupte www.keeninc.net www.icinema.com
"Tim Patrick" <in*****@invalid.com.invalidwrote in message
news:e3*************************@newsgroups.comcas t.net...
To provide a custom sorting algorithm, implement the IComparable interface
in the class, and then craft the CompareTo override. If you look up
"IComparable interface, about IComparable interface" in the on-line help,
it will provide an example.
-----
Tim Patrick
Start-to-Finish Visual Basic 2005
>How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like {{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if I know how to create this array or whatever else method is needed.
"Anil Gupte" <an*******@icinema.comschrieb:
>I think jagged arrays are only avaialble in C#, not VB. I looked in the dynamc help and also in the books for VB that I have, but there is no mention of it.
Jagged arrays are available in VB too ('Dim x()() As String'). However, as
I missed in my previous post, it's better not to use them because you store
values of different types in the elements.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
It's a new teach-yourself-Visual-Basic type of book that comes out in about
two weeks. You can find out more at www.timaki.com.
-----
Tim Patrick
Start-to-Finish Visual Basic 2005
Thanx!
BTW, What is Start-to-Finish Visual Basic 2005?
Anil,
As the other posts said as well...
I tried to do the same thing you did as well...
In the end I used a Class.
I didnt know about Struct, but im pretty happy with the way the class
handled it for me.
M.
"Anil Gupte" <an*******@icinema.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
>
How can I dimension an array like this:
dim info(a as integer, b as string) so I can store somthing like
{{"John", 10}{"Dan", 20}{"Jane", 30}}
I want to be able to sort this array too, but I think I can swing that if
I know how to create this array or whatever else method is needed.
--
Anil Gupte www.keeninc.net www.icinema.com
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Golf Nut |
last post by:
I am finding that altering and affecting values in elements in
multidimensional arrays is a huge pain in the ass. I cannot seem to find a
consistent way to assign values to arrays. Foreach would...
|
by: Terry |
last post by:
Hi,
can someone plz tell me how multidimensional arrays (like a 2-D array)
are stored in memory? Are they like single dimensional arrays? Stored
sequentially in one "row", so to say?
Thanks
...
|
by: Charles Banas |
last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to
get some opinions and comments on it, hopefully so i can gain some
sort of insight as to why this works.
at the top of the...
|
by: Claire |
last post by:
I have a multidimensional array defined as
private double myArray = new double;
The first column of the array contains X values, the other contains Y values
I have a charting function defined as...
|
by: Ravi Singh (UCSD) |
last post by:
Hello all
I am trying to use jagged and multi-dimensional arrays in C++.
In C# these work fine
// for jagged arrays
string jaggedArray = new string ;
//for multidimensional arrays
string...
| |
by: utab |
last post by:
Hi there,
Is there a way to convert a double value to a string. I know that there
is fcvt() but I think this function is not a part of the standard
library. I want sth from the standard if...
|
by: |
last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to...
|
by: oopsatwork |
last post by:
Ok...so, I have been outside of the C world for a _very_ long
time...but not so long as to remember how to do multidimensional
arrays. So, let me state that I know how to malloc pointers to...
|
by: filippo nanni |
last post by:
Hello everybody, my question is this:
I have two multidimensional arrays and I have to create a third one (for later use) from comparing these two. Here is my example code:
//BEGIN CODE
var...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |