CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

View Poll Results: Why VB 6.0

Voters
25. You may not vote on this poll
  • My employer/school requires it - and provides a valid licensed copy

    7 28.00%
  • My employer/school requires it - I dont know if I am legal

    2 8.00%
  • Been using if for years legally and see not reason to upgrade to (free) new version

    13 52.00%
  • Got a copy of it from somewhere..

    4 16.00%
  • I didn't know any better

    1 4.00%
  • I am a caveman...

    7 28.00%
Multiple Choice Poll.
Page 26 of 29 FirstFirst ... 1623242526272829 LastLast
Results 376 to 390 of 422

Thread: Why VB 6.0??

  1. #376
    Join Date
    Jun 2008
    Posts
    592

    Re: Why VB 6.0??

    Btw you are not a professional either. so stop saying you are. I can tell by your coding mistakes. GetTickcount Can't be long. It will append zeros in the bits and turn the number very wrong. try maximizing your form and reading the time. it will be like 4444411232 , but I fixed that for you
    Last edited by Joeman; July 22nd, 2008 at 04:03 AM.
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  2. #377
    Join Date
    Jun 2008
    Posts
    6

    Smile Re: Why VB 6.0??

    i have ran both of the apps and joeman is right and i think he is being pretty
    nice about it because i would grab you by your nuts and show you no mercy


    .Net scored 3500ms Vb6 scored 100ms

    vb6 wins

    if you dont believe me i will video tape it

  3. #378
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Re: Why VB 6.0??

    Quote Originally Posted by RealityIsForLocos
    i have ran both of the apps and joeman is right and i think he is being pretty
    nice about it because i would grab you by your nuts and show you no mercy


    .Net scored 3500ms Vb6 scored 100ms

    vb6 wins

    if you dont believe me i will video tape it
    i don't believe pls video tape LOL
    ... and some think vb6 will die soon? even KKK didn't have so "warmed-up fans"... VB6 will live for at least as long as VBA and VB Script will be out there, somewhere...
    K now, after the introduction, my real comment about these tests: they do not prove anything real to anyone... especially when the test involves graphics... do you guys know that hardware is more often the cause for bottlenecks than software? as well suited is a software for the hardware on which is running... as fast it wil be! take for example 64 bit compiled code running on a 32-bit machine through WOW... most probably would be slower than 32 bit software on the same machine; try running CE software on a desktop (using a PDA image)... even that the desktop processor is faster, the same software would execute faster on a PDA with slower processor; Intel compiler optimizes better for Intel processors; applications using OpenGL will draw faster on graphics cards with better OpenGL support; numbers (X ms versus Y ms) are meaningless without environment specs... and so on...
    Conclusion: dedicated software is usually running faster; languages are NOT making applications faster or not, DEVELOPERS are responsible for that, and can have the help of compilers (and other dev tools)
    Uf... can someone please CLOSE this thread?
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

  4. #379
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Why VB 6.0??

    Quote Originally Posted by Joeman
    Here are the 2 done at fullscreen. 1280 x 1024
    Right, this was test one...... I think your results mirror the results posted here... .. BTW did you check the method that Hannes put foward.. with indepth testing of the code the time was confirmed...

    This is also pure .NET code and smoked both my code and VB6 ......

    So end of test one ... VB.NET is faster... WHY? .... Well it now includes methods to complete some of the regular tasks at a fraction of the time...

    Then we did test two ... the results returned slightly inconclusive however VB6 was faster at this point ... Many pointed out mistakes and better methods in the .NET code that may have sped it up alot.. It was basically scrapped because Test 3 was put on the bench.
    How ever this one was given to VB6.

    Test 3 - Final VB6 Code
    Here aftertaking in what was discussed in test 2, the better coded .NET version ran with equivalent times.. and when pressed harder .NET posted better times, Marginal, but better..

    .NET Can and does run marginally faster than VB6, and after Tweeking code, you can get it upto 10% faster...

    I redid TEST 3 .....
    VB.NET Full screen test here
    VB6 Full Screen test here

    And I also belive that I was the one that pointed out that some of the equvalent functions can and do have different results.. CPU Wizard pointed out the .NET manages the code and has built in checks for invalid information..

    Quote Originally Posted by Joeman
    Btw you are not a professional either. so stop saying you are. I can tell by your coding mistakes.
    .. Sorry to say, but i do belive that i'm a hell of a lot more professional than you could ever dream of becoming..

    Professionals are human and do make mistakes, and the SINGLE mistake you claim that i've made was on something that i made no claim to be 100% anyway, It was code that i quickly did between working fulltime as a professional developer, writing articles for codeguru, Helping out other CG members, and SLEEP... Between all that i also try to spend time with my wife and my grandkids...

    I also have hundreds of applications written years ago still running in there respective area's, I have put some of my Personal projects up as Open source software.. FREE for all to use as they see fit.. One has already hit the 2000 downloads mark here on CG alone.

    My professional programming ability has been demonstrated. Yours has not.
    Last edited by GremlinSA; July 22nd, 2008 at 07:40 AM. Reason: fixed Html tags
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #380
    Join Date
    Jun 2008
    Posts
    592

    Re: Why VB 6.0??

    About test1... It does work, but it only does tiling. It doesn't prove anything unless your going to keep the app tiling. In that case, it would be faster. Also, you can't use test1 for anything else, but for tiling. You can't use it to make a simple game. Also, test3 may have been faster, but it is still alot slower than the vb6 version. Did you look at the difference? Download the attachment I just did and rerun them at full screen.

    If you code professionally, I am amazed. Seriously.
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  6. #381
    Join Date
    Jun 2008
    Posts
    592

    Re: Why VB 6.0??

    Why is your test still tiling lines for? That wasn't the real test. The real test was with a music treble clef sign. ....

    Also I didn't see your vb6 code for tiling of the line. I am sure you made mistakes. Can you redirect it to me?
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  7. #382
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Why VB 6.0??

    Quote Originally Posted by Joeman
    Why is your test still tiling lines for? That wasn't the real test. The real test was with a music treble clef sign. ....

    Also I didn't see your vb6 code for tiling of the line. I am sure you made mistakes. Can you redirect it to me?
    All the links are in my previous post.

    And unles someone can come up with a different test, other than graphics, I think it's time this thread dies.

    Quote Originally Posted by RealityIsForLocos
    i have ran both of the apps and joeman is right and i think he is being pretty
    nice about it because i would grab you by your nuts and show you no mercy
    If all three tests done gave the same result i'd say fine. However to completely ignore the last two tests because the results are not what you want, and focus on only the slowest .NET code and say 'There you see .NET is 1000 times slower' is not right...

    Have a look at the .NET code Hannes posted for test 1, it performed so well that i had to escalate it up and divide the time to get a true result...

    Quote Originally Posted by Joeman
    If you code professionally, I am amazed. Seriously.
    Put up or back out.. Lets the rest of us see what you've done..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  8. #383
    Join Date
    Jun 2008
    Posts
    592

    Re: Why VB 6.0??

    I think we can agree straight apis are faster than managed .net apis, but We should come up with a better test. I just don't know what since I keep thinking simple = something visual.

    Btw, most of my code is probably against some rule on the aup or in c++

    Since you told me to post some of my work, I will give you alittle bit. Although it is still incomplete it is 100% functional.

    Code:
    #ifndef ASTORAGE_H
    #define ASTORAGE_H
    
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    #ifndef Debug_Astorage
    #define Debug_AStorage 0 // set to 1 if you want to show debug information in the console, but it will slow down the array's speed alot.
    #endif
    
    template<class YourType>
    class AList
    {
    
    public:
    
    	int Number;
    	int CreationNumber;
    
    	//private:
    
    	YourType YourObject;
    	AList * Previous;
    	AList * Next;
    
    	AList() : YourObject()
    	{
    	Number = CreationNumber = 0 ;
    	Previous = Next = NULL;
    	}
    
    };
    
    
    
    template<class YourType>
    class AStorage
    {
    
    private:
    	AList<YourType> * Current;
    	AList<YourType> * FirstRegistered;
    	AList<YourType> * LastRegistered;
    	AList<YourType> * SafeZone;
    
    
    	int Count;
    
    public:
    
    	YourType& AStorage::operator[]( int Id );
    
    	bool AddQuanity( int Amount );
    	bool RemoveCurrentId();
    	bool Remove( int Id );
    	bool Clear();
    
    	YourType* Start();
    	YourType* Next();
    	YourType* Previous();
    	YourType* End();
    
    	YourType* Add();
    	YourType* GoTo( int Id );
    
    	int FindByAddress( YourType* SearchFor );
    	int FindByValue( YourType SearchFor );
    
    	bool AddBefore(int Id);
    	bool AddAfter(int Id);
    
    	bool Swap( int Id );
    	bool MoveAfter( int Id );
    	bool MoveBefore( int Id );
    
    	bool Swap( int Id_1, int Id_2 );
    	bool MoveAfter( int Id_1, int Id_2 );
    	bool MoveBefore( int Id_1, int Id_2 );
    
    	bool ResetId( int Id );
    	bool ResetCurrentId();
    
    	int GetCurrentId();
    	int GetId( YourType * Item );
    
    	int GetCurrentCreationId();
    	int GetCreationId( YourType * Item );
    
    	int GetCount();
    
    	AStorage()
    	{
    		Count = -1;
    		Current = LastRegistered = FirstRegistered = NULL;
    		SafeZone = new AList<YourType>;
    	}
    
    };
    
    // code that can't be placed in the AStorage.cpp file because of c++ limitations..//
    
    
    template<class YourType>
    YourType& AStorage<YourType>::operator[]( int Id )
    {
    	if ( Debug_AStorage ) cout << "Array[ " << Id << " ]" << endl;
    
    	if ( GoTo( Id ) == NULL )
    	{
    
    		if ( Debug_AStorage ) cout << "A Problem has occurred. Please stay in the boundry of this array" << endl;
    
    		if ( Count + 1 == 0 )
    		{
    			cout << "This array is empty" << endl;
    			cout << "Please put something in this array first" << endl;
    		}
    
    		if ( Id <= (Count + 1) / 2)
    		{
    			if (FirstRegistered == NULL)
    			{
    				cout << "You have nothing in this array" << endl;
    				cout << "Placing you in a safe area" << endl;
    				Current = SafeZone;
    			}else{
    				cout << "I have placed you at the 0" << endl;
    				Current = FirstRegistered;
    			}
    		}
    		else
    		{
    			if (LastRegistered == NULL)
    			{
    				cout << "You have no ending in this array!!!!! Now I am very confused :(" << endl;
    				cout << "Placing you in a safe area" << endl;
    				Current = SafeZone;
    			}else{
    				cout << "I have placed you at the last registered" << endl;
    				Current = LastRegistered;
    			}
    		}
    
    	}
    
    	YourType& Sending = Current->YourObject;
    	if(Current == SafeZone) Current = NULL;
    	return Sending;
    }
    
    template<class YourType>
    bool AStorage<YourType>::AddQuanity( int Amount )
    {
    
    	if ( Debug_AStorage ) cout << "AddQuanity( " << Amount << " );" << endl;
    
    	int I = 0;
    	while ( I < Amount )
    	{
    		if ( Add() == NULL )
    		{
    
    			// adding didn't work. let's revert our steps
    			if ( Debug_AStorage ) cout << "Adding failed" << endl;
    			if ( Debug_AStorage ) cout << "Retracing steps back to where nothing was added" << endl;
    			Current = LastRegistered;
    			while ( I > 0 )
    			{
    				if ( RemoveCurrentId() != true )
    				{
    					if ( Debug_AStorage ) cout << "Something went wrong with removing the remaining enities from the AddQuanity function which returned an error" << endl;
    				}
    				I--;
    			};
    
    			return false;
    		}
    		I++;
    	}
    
    	return true;
    }
    
    template<class YourType>
    bool AStorage<YourType>::RemoveCurrentId()
    {
    
    	if ( Debug_AStorage ) cout << "RemoveCurrentId();" << endl;
    	if ( Debug_AStorage ) cout << "Removing current id" << endl;
    
    	if ( Current == NULL )
    	{
    		if ( Debug_AStorage ) cout << "Id was nulled" << endl;
    		return false;
    	}
    
    	AList<YourType> * DestroyRegistered = Current;
    	AList<YourType> * PrevRegistered = Current->Previous;
    	AList<YourType> * NextRegistered = Current->Next;
    
    	if ( PrevRegistered )
    	{
    		PrevRegistered->Next = DestroyRegistered->Next;
    	}
    	if ( NextRegistered )
    	{
    		NextRegistered->Previous = PrevRegistered;
    	}
    
    
    	while ( Current->Next != NULL )
    	{
    		Next();
    		Current->Number--;
    	};
    
    	Count--;
    	Current = PrevRegistered;
    
    	if ( DestroyRegistered == LastRegistered )
    	{
    		LastRegistered = PrevRegistered;
    	}
    	if ( DestroyRegistered == FirstRegistered )
    	{
    		Current = FirstRegistered = FirstRegistered->Next;
    	}
    
    	delete DestroyRegistered;
    
    	if ( Debug_AStorage ) cout << "Id was removed" << endl;
    	return true;
    }
    
    template<class YourType>
    bool AStorage<YourType>::Remove( int Id )
    {
    
    	if ( Debug_AStorage ) cout << "Remove( " << Id << " ); " << endl;
    
    	if ( Id > Count || Id < 0 || Current == NULL )
    	{
    		if ( Debug_AStorage ) cout << "You tried to remove an id which is out of bounds" << endl;
    		return false;
    	}
    
    	int CurrentId = Current->Number;
    	if ( GoTo( Id ) == NULL )
    	{
    		if ( Debug_AStorage ) cout << "I couldn't go to the id of " << Id << endl;
    		return false;
    	}
    	if ( RemoveCurrentId() != true )
    	{
    		if ( Debug_AStorage ) cout << "Something went wrong with the Remove function while calling RemoveCurrentId" << endl;
    		return false;
    	}
    	if ( GoTo( CurrentId ) == NULL )
    	{
    		if ( Debug_AStorage ) cout << "I couldn't go back to the original Id which was  " << CurrentId << endl;
    		return false;
    	}
    
    	if ( Debug_AStorage ) cout << "I removed id of " << Id << endl;
    	return true;
    
    }
    
    template<class YourType>
    bool AStorage<YourType>::Clear()
    {
    
    	//cout << Count << endl;
    	if ( Debug_AStorage ) cout << "Clear();" << endl;
    
    	Current = LastRegistered;
    	if ( Current == NULL )
    	{
    		if ( Debug_AStorage ) cout << "The last registered in the array was nulled, so I suppose the array is already cleared" << endl;
    		return false;
    	}
    
    	while ( Count >= 0 )
    	{
    		RemoveCurrentId();
    	};
    
    	//cout << Count << endl;
    
    }
    
    template<class YourType>
    YourType* AStorage<YourType>::Start()
    {
    
    	if ( Debug_AStorage ) cout << "Start();" << endl;
    
    	if ( Debug_AStorage ) cout << "Setting current to the first registered" << endl;
    	Current = FirstRegistered;
    	if ( Current == NULL )
    	{
    		if ( Debug_AStorage ) cout << "There is nothing in the array" << endl;
    		return NULL;
    	}
    
    	return &FirstRegistered->YourObject;
    }
    
    
    template<class YourType>
    YourType* AStorage<YourType>::Next()
    {
    
    	if ( Debug_AStorage ) cout << "Next();" << endl;
    
    	if ( Debug_AStorage ) cout << "Setting current to the next" << endl;
    	Current = Current->Next;
    	if ( Current == NULL )
    	{
    		if ( Debug_AStorage ) cout << "There is no next" << endl;
    		return NULL;
    	}
    
    	return &Current->YourObject;
    }
    
    template<class YourType>
    YourType* AStorage<YourType>::Previous()
    {
    
    	if ( Debug_AStorage ) cout << "Previous();" << endl;
    
    	if ( Debug_AStorage ) cout << "Setting current to the previous" << endl;
    	Current = Current->Previous;
    	if ( Current == NULL )
    	{
    		if ( Debug_AStorage ) cout << "There are no previous" << endl;
    		return NULL;
    	}
    
    	return &Current->YourObject;
    }
    
    
    template<class YourType>
    YourType* AStorage<YourType>::End()
    {
    
    	if ( Debug_AStorage ) cout << "End();" << endl;
    
    	if ( Debug_AStorage ) cout << "Setting current to the last registered" << endl;
    	Current = LastRegistered;
    
    	return &LastRegistered->YourObject;
    }
    
    template<class YourType>
    YourType* AStorage<YourType>::Add()
    {
    
    	if ( Debug_AStorage ) cout << "Add();" << endl;
    
    	if ( Current == NULL )
    	{
    		Current = LastRegistered = FirstRegistered = new AList<YourType>;
    		Count++;
    		return &FirstRegistered->YourObject;
    	}
    	AList<YourType> * PrevRegistered = LastRegistered;
    	try
    	{
    		LastRegistered = LastRegistered->Next = new AList<YourType>;
    	}
    	catch ( bad_alloc& )
    	{
    
    		if ( Debug_AStorage ) cout << "Error has occurred while creating a new spot. Is the computer out of memory?" << endl;
    		LastRegistered = PrevRegistered;
    		return NULL;
    
    	}
    
    	LastRegistered->Previous = PrevRegistered;
    	LastRegistered->Number = ++Count;
    	LastRegistered->CreationNumber = LastRegistered->Number;
    
    	return &LastRegistered->YourObject;
    }
    
    template<class YourType>
    YourType* AStorage<YourType>::GoTo( int Id )
    {
    
    	if ( Debug_AStorage ) cout << "GoTo( " << Id << " );" << endl;
    
    	if ( Id > Count || Id < 0 )
    	{
    		if ( Debug_AStorage ) cout << "Access is out of bounds" << endl;
    		return NULL;
    	}
    
    	if ( Current == NULL )
    	{
    
    		if ( FirstRegistered != NULL )
    		{
    			Current = FirstRegistered;
    		}
    		else
    		{
    			if ( Debug_AStorage ) cout << "First registered is nulled, so I am assuming this array is empty" << endl;
    			return NULL;
    		}
    
    	}
    
    	if ( Id == 0 )
    	{
    		Current = FirstRegistered;
    	}
    	if ( Id == LastRegistered->Number)
    	{
    		Current = LastRegistered;
    	}
    
    	while ( Current->Number != Id )
    	{
    		if ( Current->Number < Id )
    		{
    			Next();
    		}
    		else
    		{
    			Previous();
    		}
    	};
    
    	return &Current->YourObject;
    }
    
    template<class YourType>
    int AStorage<YourType>::FindByAddress( YourType* SearchFor )
    {
    
    	if ( Debug_AStorage ) cout << "FindByAddress( " << SearchFor << " );" << endl;
    
    	if ( Debug_AStorage ) cout << "Searching..." << endl;
    
    	for ( int I = 0; I <= Count; I++ )
    	{
    
    		if ( GoTo( I ) == NULL )
    		{
    			continue;
    		}
    
    		if ( Debug_AStorage ) cout << "Scanning: " << &Current->YourObject << endl;
    
    		if ( &Current->YourObject == SearchFor )
    		{
    			if ( Debug_AStorage ) cout << "Item has been found and returning with " << I << " as the id in array" << endl;
    			return I;
    		}
    
    	}
    
    	if ( Debug_AStorage ) cout << "I couldn't find what your were searching for" << endl;
    	if ( Debug_AStorage ) cout << "You were searching for " << SearchFor << endl;
    
    	return -1;
    
    }
    
    template<class YourType>
    bool AStorage<YourType>::AddBefore(int Id)
    {
    	return AddAfter(Id - 1);
    }
    
    template<class YourType>
    bool AStorage<YourType>::AddAfter(int Id)
    {
    	Add();
    	GoTo(LastRegistered->Number);
    	return MoveAfter(Id);
    }
    
    template<class YourType>
    int AStorage<YourType>::FindByValue( YourType SearchFor )
    {
    
    	if ( Debug_AStorage ) cout << "FindByValue( " << SearchFor << " );" << endl;
    
    	if ( Debug_AStorage ) cout << "Searching..." << endl;
    
    	for ( int I = 0; I <= Count; I++ )
    	{
    
    		if ( GoTo( I ) == NULL )
    		{
    			continue;
    		}
    
    		if ( Debug_AStorage ) cout << "Scanning: " << Current->YourObject << endl;
    
    		if ( Current->YourObject == SearchFor )
    		{
    			if ( Debug_AStorage ) cout << "Item has been found and returning with " << I << " as the id in array" << endl;
    			return I;
    		}
    
    	}
    
    	if ( Debug_AStorage ) cout << "I couldn't find what your were searching for" << endl;
    	if ( Debug_AStorage ) cout << "You were searching for " << SearchFor << endl;
    
    	return -1;
    
    }
    
    template<class YourType>
    bool AStorage<YourType>::Swap( int Id )
    {
    
    	// act like 5 is the one being swaped with 8..
    	// GoTo(5);
    	// Swap(8);
    
    	// 5 swaps 8
    
    	if ( Debug_AStorage ) cout << "Swap( " << Id << " );" << endl;
    
    
    	if ( Id > Count || Id < 0 || Current->Number == Id || Current == NULL )
    	{
    		if ( Current != NULL )
    		{
    			if ( Debug_AStorage ) cout << "Id of " << Id << " wasn't a valid swap" << endl;
    		}
    		else
    		{
    			if ( Debug_AStorage ) cout << "Id of " << Current->Number << " wasn't a valid swap due to it being nulled" << endl;
    		}
    
    		return false;
    	}
    
    	AList<YourType>* First = Current; // 5
    	AList<YourType>* FirstNext = First->Next; // 6
    	AList<YourType>* FirstPrevious = First->Previous; // 4
    
    	GoTo( Id ); // GoTo(8);
    
    	AList<YourType>* Second = Current; // 8
    	AList<YourType>* SecondNext = Second->Next; // 9
    	AList<YourType>* SecondPrevious = Second->Previous; // 7
    
    	GoTo( First->Number );
    
    	if ( Id == First->Number + 1 )
    	{
    		return MoveAfter( Id );	// we do this incase they are right beside each other; otherwise they will loop each other's own address by assigning there own neigherboords to each other and causes a loop
    	}
    	if ( Id == First->Number - 1 )
    	{
    		return MoveBefore( Id );	// ''
    	}
    
    
    	if ( FirstPrevious != NULL )
    	{
    		FirstPrevious->Next = Second;	// 4 points forward to 8
    	}
    	Second->Next = FirstNext;									  // 8 point forward to 6
    
    	if ( SecondPrevious != NULL )
    	{
    		SecondPrevious->Next = First;	// 7 points forward to 5
    	}
    	First->Next = SecondNext;									  // 5 points forward to 9
    
    	if ( SecondNext != NULL )
    	{
    		SecondNext->Previous = First;	// 9 points back to 5
    	}
    	First->Previous = SecondPrevious;							  // 5 points back to 7
    
    	if ( FirstNext != NULL )
    	{
    		FirstNext->Previous = Second;	// 6 points back to 8
    	}
    	Second->Previous = FirstPrevious;							  // 8 points back to 4
    
    	int LastRegisteredID = LastRegistered->Number;
    
    	if ( Id == LastRegisteredID )
    	{
    		LastRegistered = First;	// last = 5
    	}
    	if ( Id == 0 )
    	{
    		FirstRegistered = First;	 // first = 5
    	}
    
    	if ( First->Number == 0 )
    	{
    		FirstRegistered = Second;	// first = 8
    	}
    	if ( First->Number == LastRegisteredID )
    	{
    		LastRegistered = Second;	// last = 8
    	}
    
    
    	Second->Number = First->Number; // 8 = 5
    	First->Number = Id; // 5 = 8
    
    	return true; // it worked! :D
    
    }
    
    template<class YourType>
    bool AStorage<YourType>::MoveAfter( int Id )
    {
    
    	if ( Debug_AStorage ) cout << "MoveAfter( " << Id << " );" << endl;
    
    	// 5 goes after 8
    
    	if ( Id > Count || Id < -1 || Current == NULL || Current->Number == Id || Current->Number == Id + 1 )
    	{
    		if ( Debug_AStorage ) cout << "Invaild MoveAfter call" << endl;
    
    		if ( Id > Count || Id < -1 )
    		{
    			if ( Debug_AStorage ) cout << "Id to swap with is out of bounds" << endl;
    		}
    
    		return false;
    	}
    
    
    	if ( Id < 0 || Id >= LastRegistered->Number )   // do this instead because you cant really move anything before the beginning and end sense there is nothing there and this does a swap and move to make moving others to the beginning or end possible
    	{
    
    		if ( Id < 0 )
    		{
    			int Number = Current->Number;
    
    			Swap( 0 );
    			GoTo( Number );
    			return MoveAfter( 0 );
    
    		}
    
    		if ( Id >= LastRegistered->Number )
    		{
    			int Number = Current->Number;
    
    			Swap( LastRegistered->Number );
    			GoTo( Number );
    			return MoveBefore( LastRegistered->Number );
    
    		}
    
    
    	}
    
    
    	AList<YourType>* First = Current;				 // 5
    	AList<YourType>* FirstPrevious = First->Previous; // 4
    	AList<YourType>* FirstNext = First->Next;		 // 6
    
    	GoTo( Id );
    
    	AList<YourType>* Second = Current;				  // 8
    	AList<YourType>* SecondPrevious = Second->Previous; // 7
    	AList<YourType>* SecondNext = Second->Next;		 // 9
    
    	GoTo( First->Number );
    
    	if ( First == LastRegistered )
    	{
    
    		LastRegistered = FirstPrevious;
    
    	}
    
    	//going up
    	if ( FirstPrevious != NULL )
    	{
    		FirstPrevious->Next = FirstNext;	// 4 points to 6
    	}
    	Second->Next = First;											// 8 points to 5
    	First->Next = SecondNext;										// 5 points to 9
    
    	//going down
    	if ( FirstNext != NULL )
    	{
    		FirstNext->Previous = FirstPrevious;	// 6 points to 4
    	}
    	First->Previous = Second;										// 5 points to 8
    	if ( SecondNext != NULL )
    	{
    		SecondNext->Previous = First;	// 9 points to 5
    	}
    
    	// this section fixes the ordering count after moving things around in the array
    
    	bool Up = First->Number < Id;
    	bool Down = !Up;
    
    	AList<YourType>* Counter;
    
    
    	if ( Up )
    	{
    
    		if (Debug_AStorage) cout << "Number is lower than the one it is moving after" << endl;
    
    		// 5 goes after 8
    
    		Counter = First;  // 5
    
    		First->Number = Second->Number; // 5 = 8
    
    		Counter = Counter->Previous; // 8 which will be 7 when it is counted down in the loop below
    
    
    		while ( Counter != FirstPrevious )
    		{
    			Counter->Number--;			// 8, 7, 6  will be turnt to 7, 6, 5
    			Counter = Counter->Previous;  // 7, 6, 4 ... 4 will not be processed because the while loop will be broken
    		};
    
    	}
    
    	if ( Down )
    	{
    
    		if (Debug_AStorage) cout << "Number is higher than the one it is moving after" << endl;
    
    		// 8 goes after 5
    
    		Counter = First; // 8
    
    		First->Number = Second->Number + 1; // 8 = 6 = 5+1
    		Counter = Counter->Next; // 6 which will be 7 when it is counted up in the loop below
    
    
    		while ( Counter != FirstNext )
    		{
    			Counter->Number++; // 6, 7 will be turnt to 7, 8
    			Counter = Counter->Next; // 7, 9 ... 9 will not be processed because the while loop will be broken
    		};
    
    
    	}
    
    	return true;
    }
    
    template<class YourType>
    bool AStorage<YourType>::MoveBefore( int Id )
    {
    
    	if ( Debug_AStorage ) cout << "MoveBefore( " << Id << " );" << endl;
    
    	return MoveAfter( Id -1 );
    
    }
    
    template<class YourType>
    bool AStorage<YourType>::Swap( int Id_1, int Id_2 )
    {
    
    	if ( Debug_AStorage ) cout << "Swap( " << Id_1 << ", " << Id_2  << " );" << endl;
    
    	GoTo( Id_1 );
    
    	return Swap( Id_2 );
    }
    
    template<class YourType>
    bool AStorage<YourType>::MoveAfter( int Id_1, int Id_2 )
    {
    
    	if ( Debug_AStorage ) cout << "MoveAfter( " << Id_1 << ", " << Id_2 << " );" << endl;
    
    	GoTo( Id_1 );
    
    	return MoveAfter( Id_2 );
    }
    
    template<class YourType>
    bool AStorage<YourType>::MoveBefore( int Id_1, int Id_2 )
    {
    
    	if ( Debug_AStorage ) cout << "MoveBefore( " << Id_1 << ", " << Id_2  << " );" << endl;
    
    	GoTo( Id_1 );
    
    	return MoveBefore( Id_2 );
    }
    
    template<class YourType>
    bool AStorage<YourType>::ResetId( int Id )
    {
    
    	if ( Debug_AStorage ) cout << "ResetId( " << Id << " );" << endl;
    
    	int CNumber = Current->Number;
    	GoTo( Id );
    	bool val =  ResetCurrentId();
    	GoTo( CNumber );
    
    	return val;
    }
    
    template<class YourType>
    bool AStorage<YourType>::ResetCurrentId()
    {
    
    	if ( Debug_AStorage ) cout << "ResetCurrentId();" << endl;
    
    	if ( Current == NULL )
    	{
    		if ( Debug_AStorage ) cout << "Current is nulled" << endl;
    		return false;
    	}
    
    	AList<YourType>* Before = Current->Previous;
    	AList<YourType>* Present = Current;
    	AList<YourType>* Next = Current->Next;
    
    	AList<YourType>* NewOne;
    
    	try
    	{
    		NewOne = new AList<YourType>;
    	}
    	catch ( bad_alloc& )
    	{
    		if ( Debug_AStorage ) cout << "Error has occurred while creating a new spot. Is the computer out of memory?" << endl;
    		return false;
    
    	}
    	if ( Before != NULL )
    	{
    		Before->Next = NewOne;
    	}
    	if ( Next != NULL )
    	{
    		Next->Previous = NewOne;
    	}
    
    	NewOne->Number = Present->Number;
    	NewOne->CreationNumber = Present->CreationNumber;
    	NewOne->Next = Next;
    	NewOne->Previous = Before;
    
    	Current = NewOne;
    
    	// NewOne is now set
    	delete Present;
    
    	return true;
    
    
    }
    template<class YourType>
    int AStorage<YourType>::GetCurrentId()
    {
    	if ( Debug_AStorage ) cout << "GetCurrentId(); " << endl;
    	if ( Current != NULL )
    	{
    		return Current->Number;
    	}
    	else
    	{
    		if ( Debug_AStorage ) cout << "Current is nulled" << endl;
    		return -1;
    	}
    }
    
    template<class YourType>
    int AStorage<YourType>::GetId( YourType * Item )
    {
    
    	if ( Debug_AStorage ) cout << "GetId( " << Item << " );" << endl;
    	int CNumber = Current->Number;
    	FindByAddress(Item);
    	int val = Current->Number;
    	GoTo(CNumber);
    	return val;
    
    }
    
    template<class YourType>
    int AStorage<YourType>::GetCurrentCreationId()
    {
    	if ( Debug_AStorage ) cout << "GetCurrentId(); " << endl;
    	if ( Current != NULL )
    	{
    		return Current->CreationNumber;
    	}
    	else
    	{
    		if ( Debug_AStorage ) cout << "Current is nulled" << endl;
    		return -1;
    	}
    }
    
    template<class YourType>
    int AStorage<YourType>::GetCreationId( YourType * Item )
    {
    
    	if ( Debug_AStorage ) cout << "GetCreationId( " << Item << " );" << endl;
    	int CNumber = Current->Number;
    	FindByAddress(Item);
    	int val = Current->CreationNumber;
    	GoTo(CNumber);
    	return val;
    
    }
    
    
    template<class YourType>
    int AStorage<YourType>::GetCount()
    {
    	if ( Debug_AStorage ) cout << "GetCount();" << endl;
    	return Count + 1;
    }
    
    
    #endif // ASTORAGE_H
    I won't tell you what it does or how to use it, but it is an ongoing project. I am building this not to reinvent the wheel, but learn how to build that wheel

    I told you I am no pro, but I don't think I am a mere newbie.
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  9. #384
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Why VB 6.0??

    OK, this should be the final speed test, unless the results call for more.

    This time there's no graphics, just pure math, in a loop. Also a CheckBox to allow selecting one of two different algorithms. Just as with the others, the TextBox determines the number of times through, and the time is shown in the TitleBar.
    Attached Files Attached Files
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  10. #385
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Why VB 6.0??

    I should also point out, that the latest round of offending posts have not gone unnoticed. Those of you able to maintain your professionalism can give yourselves a pat on the back. The rest of you should feel free to slap yourselves silly, and may the fleas of a thousand camels infest your armpits
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  11. #386
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: Why VB 6.0??

    Might I also suggest something more complex, and look at performance for recursive algorithms? I know this allows for some variations in language use,but I still think that, as we've left graphics, it would be a useful comparison. A good algorithm might be the one at http://www.codeguru.com/forum/showthread.php?t=457281, although this would need rewriting in VB.NET, and my VB6 version could do with some clearing up...

    This, however, may not show much speed until quite a large dataset is used...suggestions?
    Last edited by javajawa; July 22nd, 2008 at 11:14 AM.
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  12. #387
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Why VB 6.0??

    I was also thinking of something along the lines of string sorting, like the dreadfully slow BubbleSort algo. It's simple enough to translate to .net without much fuss I'd think.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  13. #388
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Why VB 6.0??

    Quote Originally Posted by WizBang
    I was also thinking of something along the lines of string sorting, like the dreadfully slow BubbleSort algo. It's simple enough to translate to .net without much fuss I'd think.
    Ahh ... yes.. I'm already thinking now about This VB6 Article on sorting... It Already does tick timing on each algo ..

    I dont think that it'll take too long to duplicate it into VB.NET...

    Time to knuckle down and do some coding ...

    I think i'll do your Speed test first...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  14. #389
    Join Date
    Jun 2008
    Posts
    592

    Re: Why VB 6.0??

    Yeah we need a good example to start off with. Simple recursive stuff isn't going to state much, but actually if you compare vb6 and vb.net to c++, you will find even the smallest stuff can show you how fast c++ is. Well I was bored and I decided to convert wizbang's code to c++. Although I didn't use the gui, I only used the console, I think it came out as a nice conversion.

    Here is the c++ conversion. Now we need the .net conversion. After that. We will do something else.

    Code:
    #include <iostream>
    #include <windows.h>
    #include <math.h>
    
    using namespace std;
    
    int main()
    {
    	int I(0), J(0), K(0), T(0);
    	int Method(0);
    	SYSTEMTIME Time;
    
    	cout << "Please input the number of times to process: ";
    	cin >> J;
    	cout << endl;
    
    	cout << "Please select what method of process you want:" << endl;
    	cout << "0 to Process addition" << endl;
    	cout << "1 to Process randomization, division, multplication, power of and addition" << endl;
    	cout << endl;
    	cout << "Input: (0 or 1) ";
    	cin >> Method;
    	cout << endl;
    
    	T = GetTickCount();
    
    	for( I = 0; I <= J; I++ ){
    	  if( Method == 0 ){
    		if( K > 0xFFFFFF) K = 0;
    		K = K + 1;
    	  }else{
    		K = (rand() % 1) * 1000;
    		K = K * 2 / 3 * 5;
    		K = pow(K, 2);
    
    		GetLocalTime( &Time );
    		K = K + Time.wSecond;
    	  }
    	}
    
    	T = GetTickCount() - T;
    
    	cout << "The time to process is: " << T << "ms" << endl;
    	return 0;
    }
    Note that I didn't do error checking on the input from the console because it is very simple code. If it was mission critical, I would have
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  15. #390
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Why VB 6.0??

    Why not compare something like the ability to get real work done on real world projects? In other words, look at the bigger picture. Comparing a string sort may be interesting (um, maybe not), but in the grand scheme of things, does it really matter if one approach is 2us slower than another?

    Don't just copy over the app by doing the same approach (api's, etc.) that you did in VB6. Do it by way of a .Net approach from the ground up. For graphics work, try using WPF and see if you can recreate the music clef using the WPF primitives.

Page 26 of 29 FirstFirst ... 1623242526272829 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured