473,769 Members | 5,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, directoryListin g As New ArrayList
Then in a sub I do this

For x As Integer = 0 To sourceArray.Cou nt - 1
If sourceArray.Ite m(x).oldFileNam e.Contains(",") Then
MessageBox.Show (sourceArray.It em(x).oldfilena me)
Else
MessageBox.Show ("No comma in name!" & vbCrLf & _
sourceArray.Ite m(x).oldfilenam e)
End If
Next

Ok, now when I go to typing

sourceArray.Ite m(x).oldFileNam e

and I get this much done

sourceArray.Ite m(x).ol

or even if I just get to this

sourceArray.Ite m(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 1310
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.Cou nt - 1
myFile = DirectCast (sourceArray.It em(x), myFiles)
If myFile.oldFileN ame.Contains(", ") Then
MessageBox.Show (myFile.oldfile name)
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, directoryListin g As New ArrayList
Then in a sub I do this

For x As Integer = 0 To sourceArray.Cou nt - 1
If sourceArray.Ite m(x).oldFileNam e.Contains(",") Then
MessageBox.Show (sourceArray.It em(x).oldfilena me)
Else
MessageBox.Show ("No comma in name!" & vbCrLf & _
sourceArray.Ite m(x).oldfilenam e)
End If
Next

Ok, now when I go to typing

sourceArray.Ite m(x).oldFileNam e

and I get this much done

sourceArray.Ite m(x).ol

or even if I just get to this

sourceArray.Ite m(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******@nospa mgmail.comwrote in message
news:4e******** *************** *********@4ax.c om...
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, directoryListin g As New ArrayList
Then in a sub I do this

For x As Integer = 0 To sourceArray.Cou nt - 1
If sourceArray.Ite m(x).oldFileNam e.Contains(",") Then
MessageBox.Show (sourceArray.It em(x).oldfilena me)
Else
MessageBox.Show ("No comma in name!" & vbCrLf & _
sourceArray.Ite m(x).oldfilenam e)
End If
Next

Ok, now when I go to typing

sourceArray.Ite m(x).oldFileNam e

and I get this much done

sourceArray.Ite m(x).ol

or even if I just get to this

sourceArray.Ite m(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 "sourceArra y." 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(UBo und(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(UBo und(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 "sourceArra y." 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(UBo und(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(UBo und(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******@nospa mgmail.comwrote in message
news:k1******** *************** *********@4ax.c om...
>
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
6366
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 unecessary? Here is an example of a Python class with all three types of methods (instance, static, and class methods). # Example from Ch.23, p.381-2 of Learning Python, 2nd ed. class Multi:
15
1877
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
3482
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 click a button to determine whether the zip code is unique. If the zip code is not unique, another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip code and zipid are both passed to the lookup form/dialog by reference. I...
11
3843
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 experts. I would like to produce Javascript classes that can be "subclassed" with certain behaviors defined at subclass time. There are plenty of ways to do this through prototyping and other techniques, but these behaviors need to be static and...
3
2984
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 parameter and returns an array of datasets. The collection consists of database connection objects. Based on the simple hierarchy below, you can see that starting with the
6
4900
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
5
1471
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. When I declare an instance of "ClassA" in a thrid project I get all of the public methods/properties that are in the System.Net.Mail.MailMessage class, but I do not get any of the public methods or properties that are specirfically declared in Class B
7
2701
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 the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable>
4
3307
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? In case you are wondering, I am only curious to find out the reason for this limitation. I don't really have a need to declare extension method on non static classes. I am just curious.
0
9586
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
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 we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.