473,325 Members | 2,792 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,325 software developers and data experts.

Clearing values

My question is - how to clear variable in code?
I don't want to declare different variables for all my functions...
I've got 20 functions, that are running in application everytime i run it.
In every function i'm using the same variable.
My code read from registry values of keys. Everything is ok, but:

1) function is running and reading from registry (key exist)
2) next reading (key doesn't exist, but code take value from previous
function...)
It must clear, because declaration dwValue = 0 gives me "disable" value of a
key...
Function TcpMaxConnectResponseRetransmissions(ByVal strKomputer As String)
dim oreg
Dim dwValue
oreg = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" &
strKomputer & "\root\default:StdRegProv")
Dim vTcpMaxConnectResponseRetransmissions
Dim strKeyPath = "System\CurrentControlSet\Services\Tcpip\parameter s"
Dim strValueName = "TcpMaxConnectResponseRetransmissions"
oreg.getdwordValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue)
If dwValue.ToString = Nothing Then
vTcpMaxConnectResponseRetransmissions = "Brak"
ElseIf dwValue = 1 Then
vTcpMaxConnectResponseRetransmissions = "Enabled"
ElseIf dwValue = 0 Then
vTcpMaxConnectResponseRetransmissions = "Brak"
End If
Return vTcpMaxConnectResponseRetransmissions
End Function
Nov 21 '05 #1
2 1442
Hello,

It is not good practice to reuse variables in this manner, but if you were
then you should set the variable name to = nothing before attempting to use
it again.

i.e.

Set dwValue = Nothing

HTH

<M>ike

"Leszek Gruszka" <le******@poczta.onet.pl> wrote in message
news:ci**********@81.210.18.210...
My question is - how to clear variable in code?
I don't want to declare different variables for all my functions...
I've got 20 functions, that are running in application everytime i run it.
In every function i'm using the same variable.
My code read from registry values of keys. Everything is ok, but:

1) function is running and reading from registry (key exist)
2) next reading (key doesn't exist, but code take value from previous
function...)
It must clear, because declaration dwValue = 0 gives me "disable" value of a key...
Function TcpMaxConnectResponseRetransmissions(ByVal strKomputer As String)
dim oreg
Dim dwValue
oreg = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" &
strKomputer & "\root\default:StdRegProv")
Dim vTcpMaxConnectResponseRetransmissions
Dim strKeyPath = "System\CurrentControlSet\Services\Tcpip\parameter s"
Dim strValueName = "TcpMaxConnectResponseRetransmissions"
oreg.getdwordValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue)
If dwValue.ToString = Nothing Then
vTcpMaxConnectResponseRetransmissions = "Brak"
ElseIf dwValue = 1 Then
vTcpMaxConnectResponseRetransmissions = "Enabled"
ElseIf dwValue = 0 Then
vTcpMaxConnectResponseRetransmissions = "Brak"
End If
Return vTcpMaxConnectResponseRetransmissions
End Function

Nov 21 '05 #2
Thanks!
I did it 10 minutes ago :)

U¿ytkownik "<M>ike" <mikedotdinnisatabraxas-ukdotcom> napisa³ w wiadomo¶ci
news:eP**************@TK2MSFTNGP15.phx.gbl...
Hello,

It is not good practice to reuse variables in this manner, but if you were
then you should set the variable name to = nothing before attempting to use it again.

i.e.

Set dwValue = Nothing

HTH

<M>ike

"Leszek Gruszka" <le******@poczta.onet.pl> wrote in message
news:ci**********@81.210.18.210...
My question is - how to clear variable in code?
I don't want to declare different variables for all my functions...
I've got 20 functions, that are running in application everytime i run it. In every function i'm using the same variable.
My code read from registry values of keys. Everything is ok, but:

1) function is running and reading from registry (key exist)
2) next reading (key doesn't exist, but code take value from previous
function...)
It must clear, because declaration dwValue = 0 gives me "disable" value of
a
key...
Function TcpMaxConnectResponseRetransmissions(ByVal strKomputer As

String) dim oreg
Dim dwValue
oreg = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" &
strKomputer & "\root\default:StdRegProv")
Dim vTcpMaxConnectResponseRetransmissions
Dim strKeyPath = "System\CurrentControlSet\Services\Tcpip\parameter s"
Dim strValueName = "TcpMaxConnectResponseRetransmissions"
oreg.getdwordValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue) If dwValue.ToString = Nothing Then
vTcpMaxConnectResponseRetransmissions = "Brak"
ElseIf dwValue = 1 Then
vTcpMaxConnectResponseRetransmissions = "Enabled"
ElseIf dwValue = 0 Then
vTcpMaxConnectResponseRetransmissions = "Brak"
End If
Return vTcpMaxConnectResponseRetransmissions
End Function


Nov 21 '05 #3

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

Similar topics

0
by: Jeff Levinson [mcsd] | last post by:
Not as far as I know. The easiest way is just to create a loop to set all of the controls values to "". You'll probably have to use a typeof statement to come up with specific clearing methods for...
2
by: Robin | last post by:
Ok, I have a form that on clicking of the Update button first updates the specific record in the db, then Inserts if the vMemo field is not empty. The problem that I'm having is that After...
2
by: Woodster | last post by:
I am using std::stringstream to format a string. How can I clear the stringstream variable I am using to "re use" the same variable? Eg: Using std::string std::string buffer; buffer =...
1
by: hortoristic | last post by:
We are using JavaScript to Enable/Disable certain fields on web pages based on business rules. A simple example is if when using an option type tag, and the two options are Yes and No. If YES...
12
by: Hans B | last post by:
Please bear with me if I ask silly questions....I am a somewhat newbie to the C language.... If I had: struct test1_{ unsigned char mycount1; unsigned short mycount2; unsigned short...
0
by: Nikki | last post by:
Hi, I m developing a windows c#.NET application in which text scrolls from right to left (STOCK TICKER). While scrolling the text keeps changing. (TICKER VALUES KEEP UPDATING) Now the problem that...
2
by: John Smith | last post by:
Hi folks, I have a form with ASP.NET web controls. At the end of the form there's the "Clear" button to clear the available values and start over. How do I do that? The following did not work...
1
by: Shahid Juma | last post by:
Hi, I have a form and when the user clicks save, it will add all the details to the database. However, when I add it to the database, how do I clear the form values? What happens is that it...
0
by: PD | last post by:
I am trying to stream out a PDF file via the response object and when I execute the code it always brings up the first document that I pulled up.Even when I step through the code, I can see the new...
1
by: Vayse | last post by:
I have a databound form, frmClients. One of the field is a combo box, comDepartment, which lets a user select a department for the Client. But I can't figure out how to clear the box. That is,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.