|
-
Jan 23rd, 2007, 05:01 PM
#1
Thread Starter
Member
Recursion, Polymorphism, and Overloading
It seems to me that they're not possible in VB 6... am I incorrect?
Last edited by CyberInfantry; Jan 23rd, 2007 at 07:14 PM.
Reason: Updating Title
-
Jan 23rd, 2007, 05:14 PM
#2
PowerPoster
Re: Recursion, Polymorphism
Direct polymorphism (mutation of data within a program to generate a file that runs the same but is internally different) is impossible because Windows locks a file that is being run, so no. However, using program A (the main program) to write a stub program (we'll call it program B) then terminating and passing control to program B then program B doing the changes...that's possible :-)
You should look at:
http://en.wikipedia.org/wiki/Polymorphic_code
http://en.wikipedia.org/wiki/Self-modifying_code
Note that the second link points out CLEARLY why this is not possible..."Because of the security implications of self-modifying code, some operating systems go to lengths to rule it out."
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jan 23rd, 2007, 05:17 PM
#3
Thread Starter
Member
Re: Recursion, Polymorphism
I think I may be confused about polymorphism, then.
I was wanting to do two bits of code, depending on the data sent to them.
Function diceRoller(ByVal numOne as Interger)
and
Function Dicroller (ByVal numOne as Interger, ByVal numTwo as Inerger)
That kinda thing.
-
Jan 23rd, 2007, 05:19 PM
#4
Addicted Member
Re: Recursion, Polymorphism
I don't think VB6 supported overloading values.
-
Jan 23rd, 2007, 05:27 PM
#5
Thread Starter
Member
Re: Recursion, Polymorphism
Overloading! That's it.
So we've decided Overloading and direct Polymorphism are out. What about Recursion?
-
Jan 23rd, 2007, 05:28 PM
#6
Re: Recursion, Polymorphism
Function DiceRoller(ByVal numOne As Integer, Optional ByVal numTwo As Integer = 0)
See 'Function Statement' in VB help files
-
Jan 23rd, 2007, 05:30 PM
#7
PowerPoster
Re: Recursion, Polymorphism
VB6 allows for optional values, so you could do
Function Diceroller (ByVal numOne as Interger, Optional ByVal numTwo as Inerger)
you could then do Diceroller(1,2) or Diceroller(1,) (or something like that)
Edit: Damn, someone else got there first :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jan 23rd, 2007, 05:32 PM
#8
Thread Starter
Member
Re: Recursion, Polymorphism
You guys are awesome. 
Any scoop on "Recursion"?
Last edited by CyberInfantry; Jan 23rd, 2007 at 05:33 PM.
Reason: Left off my question follow-up.
-
Jan 23rd, 2007, 05:33 PM
#9
PowerPoster
Re: Recursion, Polymorphism
If you give more information about what you're trying to achieve, we might be able to make other suggestions about ways of going about it. But glad we could help :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jan 23rd, 2007, 05:36 PM
#10
Thread Starter
Member
Re: Recursion, Polymorphism
I'm just asking if it's possible, really. :P
I remember many problems I had with it in Java, but I also recalled that when I had taken VB the year before, it wouldn't all fuctions to call themselves.
I really liked the resursive sorting and such that it does. Highly inefficient, but very fast.
-
Jan 23rd, 2007, 05:41 PM
#11
PowerPoster
Re: Recursion, Polymorphism
I'm not sure what you mean by recursion. I know what recursion is, but I've never personally written anything that recursively does stuff in a program...I do my best to be efficient :-)
Edit: However, I *have* seen something recently that uses a similar "recursion" to the one in http://en.wikipedia.org/wiki/Recursion for the factorial...it was posted here in classic VB so I can assume that recursion is doable in VB in much the same way as on wikipedia
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jan 23rd, 2007, 05:49 PM
#12
Thread Starter
Member
Re: Recursion, Polymorphism
It was inefficient in a good way... I think it's binary sorting or something, I can't really remember.
I know it used recursion. :P I believe my instructor said it was one of the fastest ways to sort, it was... just inefficient.
-
Jan 23rd, 2007, 05:50 PM
#13
Re: Recursion, Polymorphism
Recursion (by definition) is simple:
VB Code:
Sub SayHello(ByVal NumTimes As Integer)
If NumTimes > 0 Then
MsgBox "Hello!"
NumTimes = NumTimes - 1
SayHello(NumTimes)
End If
End Sub
Of course, this example is a silly way to code a simple loop, but it demonstrates recursion at a very basic level.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|