Nazgulled Posted September 17, 2004 Posted September 17, 2004 (edited) Hi, It's like this: I have one form (Form1) and I have one Module. Module Code Module Module1 Public Sub Main() [iMPORTANT LINE OF CODE] Dim Form1 As New Form1 Just_A_Function() Application.Run(Form1) End Sub Public Sub Just_A_Function() Form1.Text = "Form1 Title" End Sub End Module This won't work as you can see and coul be easly fixed if I declared Dim Form1 As New Form1 outside of the Sub Main, however, this declaration must be after [iMPORTANT LINE OF CODE]. That important line of code is a dll control I found on the internet so my application uses XP Visual Styles and that line of code must be before the form is created so I need to put it before I delcare Form1, since I am declaring it as New. How can I fix this? Isn't there a way to declare a public variable in a local variable declaration? Or some other way around to fix it? Thanks in advance. Edited September 17, 2004 by Nazgulled Quote
bri189a Posted September 17, 2004 Posted September 17, 2004 Without know anything about that line of code or what it does it's hard to say what your problem is. More than likely your implementation of this function in the dll is incorrect. The place where you got the dll from should supply usage if they documented it like they should of, even they didn't I'd find another source; people who can't document there on product usually don't have a product worth using. Most people hate XP styling anyway... I know if I had a program that forced me to look at that bubbly crap it would go out the window in a second. Generally you don't want to mess with the main function in any kind of way other than checking parameters passed into it. I'd check your usuage. Quote
Nazgulled Posted September 17, 2004 Author Posted September 17, 2004 First, when I said XP Visual Styles I didn't mean the use had to use them/seem them by force... It's support for them, that means if you use TGTSoft StyleXP or the UXTheme Patch so you could change visual styles without using programs like WindowBlinds, my application will get skinned too, othewise, it won't, that's what this dill component does, it does not force you to use the Luna Visual Styles. The component I'm using is this: http://www.skybound.ca/developer/visualstyles/ They have documentation, who said they didn't? Why are you being so harsh on them? You didn't even knew what I was talking about or the people who wrote it or if they had or not documentation... That line of code is the following: Skybound.VisualStyles.VisualStyleProvider.EnableVisualStyles() cuz just adding the dll to you rapplication won't do anything, you must call that to initialize the component, and it must be done before creating the form. In the documentation they have it like this: [Visual Basic] Public Shared <STAThread()> _ Sub Main() Skybound.VisualStyles.VisualStyleProvider.EnableVisualStyles() Application.Run(New Form1()) End Sub Quote
Administrators PlausiblyDamp Posted September 17, 2004 Administrators Posted September 17, 2004 Could you not modify the function so that it accepts a form as a parameter and then pass the variable Form1 in? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Nerseus Posted September 17, 2004 *Experts* Posted September 17, 2004 Or even have the function return the string? Module Module1 Public Sub Main() [iMPORTANT LINE OF CODE] Dim Form1 As New Form1 Form1.Text = Just_A_Function() Application.Run(Form1) End Sub Public Function Just_A_Function() As String ' Don't know the VB.NET syntax Return "Form1 Title" OR Just_A_Function = "Form1 Title" End Sub End Module -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Nazgulled Posted September 17, 2004 Author Posted September 17, 2004 @PlausiblyDamp could you please give me an example? my main langauge is not english and there are some "coding language" that I don't fully understand, so, I didn't exactly understood what you asked me... @Nerseus I don't think that will be an option, you see, that was an example. In fact, I have more than 1 function and depending on the functions I have lots of properties to change in the form... Quote
Administrators PlausiblyDamp Posted September 17, 2004 Administrators Posted September 17, 2004 Public Sub Main() [iMPORTANT LINE OF CODE] Dim AForm As New Form1 Just_A_Function(AForm) Application.Run(Form1) End Sub Public Sub Just_A_Function(frm as Form) frm.Text = "Form1 Title" End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nazgulled Posted September 17, 2004 Author Posted September 17, 2004 I porbably wouldn't be able to do that because I can't use any parameter on Application.Run as I want it to start hidden and it won't if I do Application.Run(Form1) I know that my example was like that and maybe I mislead(does this word even exist) you a bit... However, someone suggested me the following code (wich happened to work well for me): Module Module1 Dim Form1 As Form1 Public Sub Main() [iMPORTANT LINE OF CODE] Form1 = New Form1 Just_A_Function() Application.Run(Form1) End Sub Public Sub Just_A_Function() Form1.Text = "Form1 Title" End Sub End Module Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.