Mirage Source
http://web.miragesource.net/forums/

Pro Tips
http://web.miragesource.net/forums/viewtopic.php?f=143&t=5460
Page 1 of 1

Author:  Rian [ Sat Apr 11, 2009 12:08 am ]
Post subject:  Pro Tips

This is a thread intended to hopefully help people learn their ways around the VB6 IDE. I'll get the ball rolling with a shortcut I've known about in windows for years, but it was only 4 or 5 months ago that I realized you could do it within the VB6 IDE as well.

Tip #1
If you have several labels, say 10 or so, and they all have an opaque backstyle that you'd like to change to transparent. Click one label, and then control click the other nine. This selects them all at once. Then you can go to the properties box, and change the backstyle to transparent. The changes will apply to all ten labels.

Author:  Jacob [ Sat Apr 11, 2009 1:00 am ]
Post subject:  Re: Pro Tips

F5: Compiles and runs the code.
CTRL+F5: Debug + Compile and runs the code. -> I always use this to catch a lot of small bugs. Usually mistyping.

I'm surprised how many people don't know about the debug compile.

Author:  GIAKEN [ Sat Apr 11, 2009 1:18 am ]
Post subject:  Re: Pro Tips

I always run with full compile in the IDE...I don't think I've ever ran without it through the IDE.

Author:  Robin [ Sat Apr 11, 2009 7:52 am ]
Post subject:  Re: Pro Tips

Pressing Ctrl & H will allow you to replace certain text with new text. Very useful when re-naming variables or correcting spelling mistakes. eg. Changing all 'armor' to 'armour'.

Pressing F2 will bring up the Object Browser. In here, you can find out all the different data types, VB6 constants and things like that, and if you click on them you get a brief description and a simple syntax example. You can also find a specific description by right-clicking it in the code, and selecting 'Definition'.

F8 and Shift+F8 allow you to step into, and step over whilst debugging your code. Very useful when you need to go through some code step-by-step whilst it's running.

Click on the left margin next to your code, you can add a little red dot. If you run the program now, whenever this line of code is executed, the program will pause and highlight the line. Another good debug tool.

Have 'Option Explicit' at the top of every module/form/class you create. Most decent programming languages force you to explicitely declare variables before you use them. VB6 allows you to just ignore this. Some people see it as an advantage of VB6... but it's not! Not only does this make memory management a nightmare, as everything will be created as a variant (Which has it's uses, don't get me wrong), it creates a new variable every time it sees a new variable name in the code. If you misspell something, it'll just create another variable. This makes debugging incredibly hard.

ByRef and ByVal both have their uses. ByVal copies the memory across, making an entirely new value within the subroutine/function for you to use. ByRef simply acts as a referencer, and lets you edit the variable directly. Example. Imagine I'm calling the subroutine with my 'globalString' value for the sString.
Code:
Sub AddRobinToString(byval sString as string)
sString = sString & "Robin"

globalString = sString
end sub


Code:
Sub AddRobinToString(byref sString as string)
sString = sString & "Robin"
end sub


As you can see, the first subroutine is very limited. I can only hardcode it to have one string which adds 'Robin' to it. The second subroutine will handle any string sent to it, because all it did was reference the original variable.

Author:  Labmonkey [ Sat Apr 11, 2009 1:58 pm ]
Post subject:  Re: Pro Tips

Highlighting a block of code and hitting shift+tab unindents it.

Author:  Egon [ Sat Apr 11, 2009 5:36 pm ]
Post subject:  Re: Pro Tips

Labmonkey wrote:
Highlighting a block of code and hitting shift+tab unindents it.

I love you.

Author:  Matt [ Sat Apr 11, 2009 5:39 pm ]
Post subject:  Re: Pro Tips

Egon wrote:
Labmonkey wrote:
Highlighting a block of code and hitting shift+tab unindents it.

I love you.


That works outside of VB too. :P

I always thought it was common sense. Shift + tab will also tab backwards through text boxes and what not.

Author:  Labmonkey [ Sat Apr 11, 2009 5:50 pm ]
Post subject:  Re: Pro Tips

Egon wrote:
Labmonkey wrote:
Highlighting a block of code and hitting shift+tab unindents it.

I love you.


Oh no! The prophecy is coming true!

GIAKEN wrote:
I think what I see is this happening:

Labmonkey gets mod, everybody loves him, people find out his code sucks, he gets demoted, then banned, then he makes an engine called Chaos Engine.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/