473,387 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to make my own classes show their methods and/or variables while typing?

Sorry, but I have no idea how to phrase the subject better than that.
I've come across this a few different times and decided to ask in case
there's a way to do it. It would simplify things a bit and I figured
if anyone knows, more than likely that someone is here.

I have a class for storing filenames and it's path along with a little
more info. Here it is

Public Class myFiles
Public oldFileName As String
Public oldPathAndName As String
Public newFileName As String
Public newPathAndName As String
Public fileExtention As String
End Class

Now when using functions and such that are built in and you begin
typing VS.net either pops up with what you can possibly use or you can
force it by ctrl+space. Thats pretty much what I want to do. I may be
doing something wrong that is making it so it isn't including it, but,
if so hopefully any replies will point that out to me.

I declare a new arraylist

Public sourceArray, directoryListing As New ArrayList
Then in a sub I do this

For x As Integer = 0 To sourceArray.Count - 1
If sourceArray.Item(x).oldFileName.Contains(",") Then
MessageBox.Show(sourceArray.Item(x).oldfilename)
Else
MessageBox.Show("No comma in name!" & vbCrLf & _
sourceArray.Item(x).oldfilename)
End If
Next

Ok, now when I go to typing

sourceArray.Item(x).oldFileName

and I get this much done

sourceArray.Item(x).ol

or even if I just get to this

sourceArray.Item(x).

pressing ctrl+space should popup, or at least I would like it to, the
possible variables/methods/fuctions/etc.. I have for that class
stored in the arraylist. Did I explain this enough for you to
understand what I'm trying to accomplish? If so, is there a way for me
to get the classes variables to popup in the drop down box of the
'code completer'?

Even though it doesn't automatically popup for quicker completion it
does work just fine when I run it. But my memory isn't the greatest
for all the different names and such I use in different parts of my
project and would love to have the 'code completer' assist me with
this.
Thank you in advance for any help anyone can provide.
-------
Kyote
Please reply to the group.
Jul 27 '06 #1
5 1291
oops! I forgot to mention I'm using VS.NET 2005
Jul 27 '06 #2
Kyote,

The arraylist holds objects. You need to cast the object back to an instance
of your class.

For example:

Dim myFile As myFiles
For x As Integer = 0 To sourceArray.Count - 1
myFile = DirectCast (sourceArray.Item(x), myFiles)
If myFile.oldFileName.Contains(",") Then
MessageBox.Show(myFile.oldfilename)
etc.

Another option would be to use a List instead of ArrayList and have it only
contain objects of type myFiles.

Kerry Moorman
"Kyote" wrote:
Sorry, but I have no idea how to phrase the subject better than that.
I've come across this a few different times and decided to ask in case
there's a way to do it. It would simplify things a bit and I figured
if anyone knows, more than likely that someone is here.

I have a class for storing filenames and it's path along with a little
more info. Here it is

Public Class myFiles
Public oldFileName As String
Public oldPathAndName As String
Public newFileName As String
Public newPathAndName As String
Public fileExtention As String
End Class

Now when using functions and such that are built in and you begin
typing VS.net either pops up with what you can possibly use or you can
force it by ctrl+space. Thats pretty much what I want to do. I may be
doing something wrong that is making it so it isn't including it, but,
if so hopefully any replies will point that out to me.

I declare a new arraylist

Public sourceArray, directoryListing As New ArrayList
Then in a sub I do this

For x As Integer = 0 To sourceArray.Count - 1
If sourceArray.Item(x).oldFileName.Contains(",") Then
MessageBox.Show(sourceArray.Item(x).oldfilename)
Else
MessageBox.Show("No comma in name!" & vbCrLf & _
sourceArray.Item(x).oldfilename)
End If
Next

Ok, now when I go to typing

sourceArray.Item(x).oldFileName

and I get this much done

sourceArray.Item(x).ol

or even if I just get to this

sourceArray.Item(x).

pressing ctrl+space should popup, or at least I would like it to, the
possible variables/methods/fuctions/etc.. I have for that class
stored in the arraylist. Did I explain this enough for you to
understand what I'm trying to accomplish? If so, is there a way for me
to get the classes variables to popup in the drop down box of the
'code completer'?

Even though it doesn't automatically popup for quicker completion it
does work just fine when I run it. But my memory isn't the greatest
for all the different names and such I use in different parts of my
project and would love to have the 'code completer' assist me with
this.
Thank you in advance for any help anyone can provide.
-------
Kyote
Please reply to the group.
Jul 28 '06 #3

"Kyote" <tr******@nospamgmail.comwrote in message
news:4e********************************@4ax.com...
Sorry, but I have no idea how to phrase the subject better than that.
I've come across this a few different times and decided to ask in case
there's a way to do it. It would simplify things a bit and I figured
if anyone knows, more than likely that someone is here.

I have a class for storing filenames and it's path along with a little
more info. Here it is

Public Class myFiles
Public oldFileName As String
Public oldPathAndName As String
Public newFileName As String
Public newPathAndName As String
Public fileExtention As String
End Class

Now when using functions and such that are built in and you begin
typing VS.net either pops up with what you can possibly use or you can
force it by ctrl+space. Thats pretty much what I want to do. I may be
doing something wrong that is making it so it isn't including it, but,
if so hopefully any replies will point that out to me.

I declare a new arraylist

Public sourceArray, directoryListing As New ArrayList
Then in a sub I do this

For x As Integer = 0 To sourceArray.Count - 1
If sourceArray.Item(x).oldFileName.Contains(",") Then
MessageBox.Show(sourceArray.Item(x).oldfilename)
Else
MessageBox.Show("No comma in name!" & vbCrLf & _
sourceArray.Item(x).oldfilename)
End If
Next

Ok, now when I go to typing

sourceArray.Item(x).oldFileName

and I get this much done

sourceArray.Item(x).ol

or even if I just get to this

sourceArray.Item(x).

pressing ctrl+space should popup, or at least I would like it to, the
possible variables/methods/fuctions/etc.. I have for that class
stored in the arraylist. Did I explain this enough for you to
understand what I'm trying to accomplish? If so, is there a way for me
to get the classes variables to popup in the drop down box of the
'code completer'?

Even though it doesn't automatically popup for quicker completion it
does work just fine when I run it. But my memory isn't the greatest
for all the different names and such I use in different parts of my
project and would love to have the 'code completer' assist me with
this.
Just a quick read of your example code and your desired behavior...

.... you have sourceArray defined as an ArrayList object. The Class myFiles
is not referenced. That is part of the reason why typing "sourceArray." does
not yield the Properties/Methods of the myFiles Class.

If sourceArray were an array of myFiles, and there were Property Get/Let's
for the objects in the myFiles Class, you would get the desired behavior.

Assuming your myFiles Class, with the addition of Property Get/Let's, you
could define sourceArray as...

Private sourceArray() As myFiles

You would ReDim sourceArray as needed to grow the array.

There are other tricks. This is but the most simple of examples (IMO, of
course). There might even be an error in the following 'cus the coffee has
yet to kick in for the morning.

If you haven't used ReDim on an empty array, the one thing you'll notice is
attempting to detect the empty array using Nothing or UBound/LBound will not
yield the desired outcome. You have to trap a runtime error condition.

There is overhead with ReDim'ing arrays. If you are working with small
arrays and not ReDim'ing the heck out of them the overhead should be
tollerable.

=====myFiles Class=====
Public Class myFiles
Private m_oldFileName As String
Property oldFileName() As String
Get
oldFileName = m_oldFileName
End Get
Set(ByVal value As String)
m_oldFileName = value
End Set
End Property
End Class
=====End myFiles Class=====

=====Some other Class=====
Public Class DummyForm
Private sourceArray() As myFiles ' empty array, no rows defined yet
Private Sub GrowArray()
On Error Resume Next
ReDim Preserve sourceArray(UBound(sourceArray) + 1)
If Err Then
ReDim sourceArray(0) ' one row array
End If
On Error GoTo 0
' Do other array entry initialization stuff here including...
sourceArray(UBound(sourceArray)) = New myFile
End Sub
End Class
=====End some other Class=====
Jul 28 '06 #4
>Just a quick read of your example code and your desired behavior...
>
... you have sourceArray defined as an ArrayList object. The Class myFiles
is not referenced. That is part of the reason why typing "sourceArray." does
not yield the Properties/Methods of the myFiles Class.

If sourceArray were an array of myFiles, and there were Property Get/Let's
for the objects in the myFiles Class, you would get the desired behavior.

Assuming your myFiles Class, with the addition of Property Get/Let's, you
could define sourceArray as...

Private sourceArray() As myFiles

You would ReDim sourceArray as needed to grow the array.

There are other tricks. This is but the most simple of examples (IMO, of
course). There might even be an error in the following 'cus the coffee has
yet to kick in for the morning.

If you haven't used ReDim on an empty array, the one thing you'll notice is
attempting to detect the empty array using Nothing or UBound/LBound will not
yield the desired outcome. You have to trap a runtime error condition.

There is overhead with ReDim'ing arrays. If you are working with small
arrays and not ReDim'ing the heck out of them the overhead should be
tollerable.

=====myFiles Class=====
Public Class myFiles
Private m_oldFileName As String
Property oldFileName() As String
Get
oldFileName = m_oldFileName
End Get
Set(ByVal value As String)
m_oldFileName = value
End Set
End Property
End Class
=====End myFiles Class=====

=====Some other Class=====
Public Class DummyForm
Private sourceArray() As myFiles ' empty array, no rows defined yet
Private Sub GrowArray()
On Error Resume Next
ReDim Preserve sourceArray(UBound(sourceArray) + 1)
If Err Then
ReDim sourceArray(0) ' one row array
End If
On Error GoTo 0
' Do other array entry initialization stuff here including...
sourceArray(UBound(sourceArray)) = New myFile
End Sub
End Class
=====End some other Class=====
What I'm doing is adding an instance of myFiles to the sourceArray
arraylist. That way I can avoid having to redim anything and also
avoid the redimming overhead.

My program is going to parse filenames and create directories based on
certain filename templates. Then it will move the files into the
appropriate directory. The reason I'm doing it this way is because it
allows me to keep all the information together and I can then send
only specific parts to my parsing subs which will then add the missing
information to each set of variables in each object in the arraylist.

I tried to think it through and determine the best approach for doing
what I wanted this app to do but I found myself not wanting to begin
because I could think of so many different ways to approach it. So
finally I decided to just do it and make alterations as my knowledge
grew. I know that's not really a good way to go about it but this app
is just a little tool to make certain things I do for a hobby of mine
easier to do. The added benefit is that it helps me learn vb.net a
little better as well.

So, is there a way for me to get the auto complete to appear doing it
the way I am? Or should I change my class to use get and sets as you
suggested?
-------
Kyote
Please reply to the group.
Jul 28 '06 #5

"Kyote" <tr******@nospamgmail.comwrote in message
news:k1********************************@4ax.com...
>
What I'm doing is adding an instance of myFiles to the sourceArray
arraylist. That way I can avoid having to redim anything and also
avoid the redimming overhead.

My program is going to parse filenames and create directories based on
certain filename templates. Then it will move the files into the
appropriate directory. The reason I'm doing it this way is because it
allows me to keep all the information together and I can then send
only specific parts to my parsing subs which will then add the missing
information to each set of variables in each object in the arraylist.

I tried to think it through and determine the best approach for doing
what I wanted this app to do but I found myself not wanting to begin
because I could think of so many different ways to approach it. So
finally I decided to just do it and make alterations as my knowledge
grew. I know that's not really a good way to go about it but this app
is just a little tool to make certain things I do for a hobby of mine
easier to do. The added benefit is that it helps me learn vb.net a
little better as well.

So, is there a way for me to get the auto complete to appear doing it
the way I am? Or should I change my class to use get and sets as you
suggested?
'Tho I haven't done (or seen) benchmarks comparing ReDim to ArrayList, I
suspect they will be about equal since both are expanding/contracting array
structures of some sort and that tends to be a memory-intensive process
(relatively speaking). Actual use of the array, I suspect, will have less
overhead than the ArrayList; I seem to recall ArrayList as being based on a
Collection and those tend to be slow, at least large Collections and in VB
classic.

Tinkering with code, especially new libraries, is a great way to pick up
skills and knowledge (IMO, of course). The "best approach" is the one that
works for you. I sometimes find myself pondering an idea for days on end
just trying to determine how I want to structure the solution. When it comes
time to write the code though it is not unusual for the whole idea to go
south and I end up falling back on old solutions. (Ah, but it is all about
the hunt. That's why they call fishing "fishing." If it were about actually
catching fish it would be called "catching.")

Some people (me) absolutely love to stumble around in the dark just for the
challenge. Others prefer the safety of a guided tour. Flailing around in
code allows you to discover alternative ways of accomplishing the task and,
in the process, generates far more intimate knowledge of the things you
touch along the way than any book or "expert" site can provide; the
knowledge sticks if you uncover it on your own and yields a certain
satisfaction once a solution is discovered. But enough of the soapbox
speech...

The only ways I know of that will give you the "auto complete" are defining
an object as a Class, a Structure (Type in VB classic), or an Enum. Since
your needs seem to indicate the "thing" requires validation routines and
other supporting code specific to this type of object, I would personally
use a Class. How that works in conjunction with ArrayList, I don't know
(yet). There is probably a slick trick, not necessarily inheritance, that
will allow you to use the Class with ArrayList yielding the best of both
worlds.

For now, the question you have to answer is which of the two - auto complete
or ArrayList - is of more value to you at the moment.
Jul 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

145
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity...
15
by: Duncan Lissett | last post by:
I'd appreciate any suggestions on how to make faster Python implementations of Richards benchmark. Perhaps there are obvious problems that can be corrected? http://www.lissett.com/ben/bench1.htm
11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
3
by: Dave | last post by:
Please - anyone that can help. I am getting confusing results while trying to expose a collection from a web service. I have a webservice in which a web method accepts a collection as a...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
5
by: D Witherspoon | last post by:
What is happening is that I have a class (ClassA) that inherits a class (ClassB) which inherits System.Net.Mail.MailMessage Project 1 references Project 2, Project 2 references Project 3. ...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
4
by: Rene | last post by:
Hi, I was wondering if anyone could tell me why extension methods must be declared on static classes. I mean, why not allowing them to be declared as static methods in regular instance classes?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.