Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by Nazgulled
Posted
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.
Posted

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

  • *Experts*
Posted

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

"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
Posted

@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...

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...