![]() |
Pro Tips - Printable Version +- Mirage Engine (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Programming (https://mirage-engine.uk/forums/forumdisplay.php?fid=24) +----- Forum: Visual Basic 6 (https://mirage-engine.uk/forums/forumdisplay.php?fid=32) +----- Thread: Pro Tips (/showthread.php?tid=2728) |
Pro Tips - Rian - 11-04-2009 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. Re: Pro Tips - Jacob - 11-04-2009 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. Re: Pro Tips - GIAKEN - 11-04-2009 I always run with full compile in the IDE...I don't think I've ever ran without it through the IDE. Re: Pro Tips - Robin - 11-04-2009 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) Code: Sub AddRobinToString(byref sString as string) 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. Re: Pro Tips - Labmonkey - 11-04-2009 Highlighting a block of code and hitting shift+tab unindents it. Re: Pro Tips - Egon - 11-04-2009 Labmonkey Wrote:Highlighting a block of code and hitting shift+tab unindents it.I love you. Re: Pro Tips - Matt - 11-04-2009 Egon Wrote:Labmonkey Wrote:Highlighting a block of code and hitting shift+tab unindents it.I love you. That works outside of VB too. ![]() I always thought it was common sense. Shift + tab will also tab backwards through text boxes and what not. Re: Pro Tips - Labmonkey - 11-04-2009 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: |