Clearing values

L

Leszek Gruszka

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=impersonate}!\\" &
strKomputer & "\root\default:StdRegProv")
Dim vTcpMaxConnectResponseRetransmissions
Dim strKeyPath = "System\CurrentControlSet\Services\Tcpip\parameters"
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
 
G

Guest

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
 
L

Leszek Gruszka

Thanks!
I did it 10 minutes ago :)

U¿ytkownik said:
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

of
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top