Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2008, 10:47 AM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I did state it, it says what the functions so in the first post, i understand what the function does to top but i dont know what they do to anArray.

 
Old January 17th, 2008, 11:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Put store the value in the array at position top.. so if you pass top=1 and char = "X" will store X at position 2 of the array..

ok?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old January 17th, 2008, 11:05 AM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey, i have completed the there tables for each input string, will you check if they are right for me please?

http://www.imagehosting.com/out.php/i1515670_cd.bmp


http://www.imagehosting.com/out.php/...2_untitled.JPG


http://www.imagehosting.com/out.php/..._untitled2.JPG

thanks!

 
Old January 17th, 2008, 11:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. I can't check if they are correct or wrong.. but glad you could sort this thing out...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old January 17th, 2008, 11:13 AM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh ok then. i dont think its all right, i might have done some of the procedures wrong.

 
Old January 17th, 2008, 11:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Well.. doing things the wrong way is part of learning too...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old January 17th, 2008, 11:33 AM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ye i know but having the right answer will help alot so i can go back and check where i went wrong and figure out why i went wrong.

 
Old January 17th, 2008, 03:44 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I presumed that these functions for Push and Pop already existed, and that you only had to use them.

Fortunately, because you can find out the status of an array, you don't need to do thing in as complex a fashion as you would if you were working in a lower-level environment.

Tp push a value onto an array, you obtain the index of the top item, add a new item to the array (that is, expand it's size by one), then add the data to that element (that is, set that new element to the value of the data).
Code:
    Dim i As Integer
        i = UBound(MyArray)
    Redim Preserve MyArray(1 to i + 1)  ' Preserve is nec. to keep 
                                          the existing values.
    MyArray(i + 1) = MyNewValue
    If you wrap all this in a routine named Push(), you can either make it a Function, returning the new size of the array, or just a Sub that handles the action details, being called from one, simple, self documenting line: Push NewValue, MyArray.

Pulling a value off the array can be done exactly the same, except you read the value at the UBound() position, then ReDim the array i - 1.

Because VB maintains UBound and LBound, you do not need to increment or decrement any variables and maintain them to keep track of what the status of your array is.

If you are working with strings, you can make this even simpler. The pushing of a value onto the end of the string is just:
Code:
    MyString = MyString & MyNewChar
The string will be expanded by 1 for you, if MyNewChar is just one character in size.

The Pop procedure would be a little more complex, but only a little:
Code:
    Dim Temp As String * 1       ' Creates a 1-character, fixed-length string
    Temp = Right$(MyString, 1)   ' Get the right-most character's value.
    MyString = Left$(MyString, Len(MyString) - 1)   ' Shorten the string by 1
 
Old February 5th, 2008, 07:15 AM
Registered User
 
Join Date: Feb 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank You,

http://www.searchfinish.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
apriori algorithm iralala J2EE 4 January 1st, 2014 06:49 PM
FTC algorithm iralala Java Databases 1 February 3rd, 2009 07:57 AM
algorithm angelboy Other Programming Languages 0 April 14th, 2007 08:56 AM
Typical Algorithm rajanikrishna ASP.NET 1.0 and 1.1 Professional 0 November 20th, 2006 03:05 AM
Algorithm kvanchi General .NET 3 January 20th, 2005 05:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.