I need help with Visual basic - Printable Version +- Renegade Projects Network Forums (https://forums.renegadeprojects.com) +-- Forum: General Forums (https://forums.renegadeprojects.com/forumdisplay.php?fid=1) +--- Forum: The Renegade Inn (https://forums.renegadeprojects.com/forumdisplay.php?fid=2) +--- Thread: I need help with Visual basic (/showthread.php?tid=1202) |
I need help with Visual basic - Professor_Tesla - 20.12.2008 I need help with fixing something really annoying in my visual basic code. I found some code on the internet for working with .ini files, and I wanted to incorporate it into a program that I have written. Here is the relevant part of the code. Code: Declare Function GetPrivateProfileString Lib "kernel32" Alias _ RE: I need help with Visual basic - Marshall - 20.12.2008 What if you put the "Private Declare Function ShellExecute" amongst the other Declare Functions, before your own routines? RE: I need help with Visual basic - Professor_Tesla - 20.12.2008 That problem seems to have been solved, but now it won't compile because "Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules". It seems to have a problem with the first two "Declare Function"s that I posted above. RE: I need help with Visual basic - Marshall - 21.12.2008 So make them Private, like ShellExecute. Or don't put them in an object module. RE: I need help with Visual basic - Professor_Tesla - 21.12.2008 I made them private and the compile errors disappeared. However, my program doesn't do anything I wanted it to. I wanted to have a program with buttons that, when clicked, would open a file in a path obtained from an INI file. When the buttons are clicked, it goes into the program's directory and minmizes the window. How do I not put the functions in an object module? RE: I need help with Visual basic - Marshall - 22.12.2008 Not knowing what problems you're having, I suggest stepping thorugh the code and/or putting debugging in to see which functions aren't working as you expect. Regarding object modules, I suspect it's complaining that you're putting the public declares in a form. Just create a module and put your public functions in that. I learned everything I know about VB by 25% trial and error, 75% googling. RE: I need help with Visual basic - Professor_Tesla - 22.12.2008 I found out what the problem is. OpenLocation doesn't seem to want to take a string variable as an argument. It only seems to accept strings enclosed in quote marks. RE: I need help with Visual basic - Marshall - 22.12.2008 I think it's more likely that there was a problem with your string var. I use Label1.Caption as the argument for OpenLocation and it works fine as long as the caption is valid. RE: I need help with Visual basic - Professor_Tesla - 23.12.2008 It's strange, but I set the caption of a Label to the value of the string variable, used the caption label as an argument for the function, and it worked. Thanks for your help. RE: I need help with Visual basic - Marshall - 23.12.2008 There must be a problem with your string variable because that should work too. RE: I need help with Visual basic - Professor_Tesla - 24.12.2008 ↠This is me. I declared the string variable inside a private subroutine. Thus, as far as the sub I was trying to use it in as an argument for a function was concerned, it didn't exist. I should have remembered that from what I learned in C programming. RE: I need help with Visual basic - Marshall - 24.12.2008 Option Explicit is your friend Put that at the beginning of every form/module. |