473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Global variables

Hello,

I am trying to create a variable when my form loads which can be used
when I click my buttons. Here is my code. What am I doing wrong?
Thanks for any help.

Private Sub Connect_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CreateObjConnect()
End Sub

Public Sub CreateObjConnect()
Dim objIco As New ICAClient
'Set Browser Protocol
objIco.BrowserProtocol = "UDP"

'Set Server locator
objIco.TCPBrowserAddress = "10.1.200.234"
'Disable IPCLaunch
objIco.IPCLaunch = False

'Set to launch, rather than embed session
objIco.Launch = True

'Enable seamless
objIco.TWIMode = True

'objIco.XmlAddressResolutionType = "IPv4-Port"
objIco.ConnectionEntry = "TEST"
objIco.WinstationDriver = "ICA 3.0"
objIco.TransportDriver = "TCP/IP"

'Set credentials
objIco.Username = "test"
objIco.SetProp("Password", "testtest")
objIco.Domain = "test"

'Specify application to launch
objIco.Application = "TEST"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
objIco.Connect()
End Sub

Jun 23 '06 #1
5 1894

try this
Dim objIco As ICAClient
Public Sub CreateObjConnect()
objIco = new ICAClient
Brian Cahill wrote:
Hello,

I am trying to create a variable when my form loads which can be used
when I click my buttons. Here is my code. What am I doing wrong?
Thanks for any help.

Private Sub Connect_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CreateObjConnect()
End Sub

Public Sub CreateObjConnect()
Dim objIco As New ICAClient
'Set Browser Protocol
objIco.BrowserProtocol = "UDP"

'Set Server locator
objIco.TCPBrowserAddress = "10.1.200.234"
'Disable IPCLaunch
objIco.IPCLaunch = False

'Set to launch, rather than embed session
objIco.Launch = True

'Enable seamless
objIco.TWIMode = True

'objIco.XmlAddressResolutionType = "IPv4-Port"
objIco.ConnectionEntry = "TEST"
objIco.WinstationDriver = "ICA 3.0"
objIco.TransportDriver = "TCP/IP"

'Set credentials
objIco.Username = "test"
objIco.SetProp("Password", "testtest")
objIco.Domain = "test"

'Specify application to launch
objIco.Application = "TEST"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
objIco.Connect()
End Sub


Jun 23 '06 #2
duh...thanks!

Ahmed wrote:
try this
Dim objIco As ICAClient
Public Sub CreateObjConnect()
objIco = new ICAClient
Brian Cahill wrote:
Hello,

I am trying to create a variable when my form loads which can be used
when I click my buttons. Here is my code. What am I doing wrong?
Thanks for any help.

Private Sub Connect_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CreateObjConnect()
End Sub

Public Sub CreateObjConnect()
Dim objIco As New ICAClient
'Set Browser Protocol
objIco.BrowserProtocol = "UDP"

'Set Server locator
objIco.TCPBrowserAddress = "10.1.200.234"
'Disable IPCLaunch
objIco.IPCLaunch = False

'Set to launch, rather than embed session
objIco.Launch = True

'Enable seamless
objIco.TWIMode = True

'objIco.XmlAddressResolutionType = "IPv4-Port"
objIco.ConnectionEntry = "TEST"
objIco.WinstationDriver = "ICA 3.0"
objIco.TransportDriver = "TCP/IP"

'Set credentials
objIco.Username = "test"
objIco.SetProp("Password", "testtest")
objIco.Domain = "test"

'Specify application to launch
objIco.Application = "TEST"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
objIco.Connect()
End Sub


Jun 23 '06 #3
What is happening in your code is when the end of CreateObjConnect is
reach the garbage collection disposes your variables. Plus, the objlco
is a local veriable to the CreateObjConnect method. Saying that, I
wonder how come you didn't get a compiling error? don't you have option
explicit on?

Ahmed

Ahmed wrote:
try this
Dim objIco As ICAClient
Public Sub CreateObjConnect()
objIco = new ICAClient
Brian Cahill wrote:
Hello,

I am trying to create a variable when my form loads which can be used
when I click my buttons. Here is my code. What am I doing wrong?
Thanks for any help.

Private Sub Connect_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CreateObjConnect()
End Sub

Public Sub CreateObjConnect()
Dim objIco As New ICAClient
'Set Browser Protocol
objIco.BrowserProtocol = "UDP"

'Set Server locator
objIco.TCPBrowserAddress = "10.1.200.234"
'Disable IPCLaunch
objIco.IPCLaunch = False

'Set to launch, rather than embed session
objIco.Launch = True

'Enable seamless
objIco.TWIMode = True

'objIco.XmlAddressResolutionType = "IPv4-Port"
objIco.ConnectionEntry = "TEST"
objIco.WinstationDriver = "ICA 3.0"
objIco.TransportDriver = "TCP/IP"

'Set credentials
objIco.Username = "test"
objIco.SetProp("Password", "testtest")
objIco.Domain = "test"

'Specify application to launch
objIco.Application = "TEST"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
objIco.Connect()
End Sub


Jun 23 '06 #4
Hello Brian,

You should read up on variable scope. You declare objIco in Sub CreateObjConnect()
(which by the way is not a very descriptive name for a method)... so when
CreateObjConnect() ends, your variable falls out of scope (ie, it's no longer
available and will be GC'd).

Declare your variable in the Class's globals section:

Public Class YourFormName

Private objIco As ICAClient = New ICAClient
Sub Connect_Load(blah, blah)
SetupICAClient()
End Sub

....

-Boo
Hello,

I am trying to create a variable when my form loads which can be used
when I click my buttons. Here is my code. What am I doing wrong?
Thanks for any help.

Private Sub Connect_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CreateObjConnect()
End Sub
Public Sub CreateObjConnect()
Dim objIco As New ICAClient
'Set Browser Protocol
objIco.BrowserProtocol = "UDP"
'Set Server locator
objIco.TCPBrowserAddress = "10.1.200.234"
'Disable IPCLaunch
objIco.IPCLaunch = False
'Set to launch, rather than embed session
objIco.Launch = True
'Enable seamless
objIco.TWIMode = True
'objIco.XmlAddressResolutionType = "IPv4-Port"
objIco.ConnectionEntry = "TEST"
objIco.WinstationDriver = "ICA 3.0"
objIco.TransportDriver = "TCP/IP"
'Set credentials
objIco.Username = "test"
objIco.SetProp("Password", "testtest")
objIco.Domain = "test"
'Specify application to launch
objIco.Application = "TEST"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles Button1.Click
objIco.Connect()
End Sub


Jun 23 '06 #5

i would like to add , that coding conventions tell us that


method scope variabels should be declared with Dim all other declarations
should be declared with there scope attribute
( eg private , friend , public )
regards

Michel Posseth [MCP]

"GhostInAK" <gh*******@gmail.com> schreef in bericht
news:be*************************@news.microsoft.co m...
Hello Brian,

You should read up on variable scope. You declare objIco in Sub
CreateObjConnect() (which by the way is not a very descriptive name for a
method)... so when CreateObjConnect() ends, your variable falls out of
scope (ie, it's no longer available and will be GC'd).

Declare your variable in the Class's globals section:

Public Class YourFormName

Private objIco As ICAClient = New ICAClient
Sub Connect_Load(blah, blah)
SetupICAClient()
End Sub

...

-Boo
Hello,

I am trying to create a variable when my form loads which can be used
when I click my buttons. Here is my code. What am I doing wrong?
Thanks for any help.

Private Sub Connect_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CreateObjConnect()
End Sub
Public Sub CreateObjConnect()
Dim objIco As New ICAClient
'Set Browser Protocol
objIco.BrowserProtocol = "UDP"
'Set Server locator
objIco.TCPBrowserAddress = "10.1.200.234"
'Disable IPCLaunch
objIco.IPCLaunch = False
'Set to launch, rather than embed session
objIco.Launch = True
'Enable seamless
objIco.TWIMode = True
'objIco.XmlAddressResolutionType = "IPv4-Port"
objIco.ConnectionEntry = "TEST"
objIco.WinstationDriver = "ICA 3.0"
objIco.TransportDriver = "TCP/IP"
'Set credentials
objIco.Username = "test"
objIco.SetProp("Password", "testtest")
objIco.Domain = "test"
'Specify application to launch
objIco.Application = "TEST"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles Button1.Click
objIco.Connect()
End Sub


Jun 24 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Matt | last post by:
Greetings, What are people's thoughts on global variables in C++? Why are we taught not to use them in programming? Is it true that if you are running two copies of the C program one copy can...
4
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); ...
12
by: David WOO | last post by:
Hi, I am a newbie on C++, I need to define some global variables which should be accessible to most classes. In the mean time, I don't won't the global variables be modified freely at most of...
2
by: Bryan Parkoff | last post by:
….I would like to know which is the best optimization to use global variable or global struct. I always tell C/C++ Compiler to turn on optimization. ….I use underscore between first name and...
17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
33
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
5
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.