Help with variables!!!

tich

Member
Joined
Jul 27, 2005
Messages
20
Location
Beirut,Lebanon
Programming Experience
3-5
Hey all,
i'm making a program that copies a file byte per byte.
I want it to copy files that windows doesn't copy: Cyclic reduncy check
So i want to override the exceotion generated by a cyclic reduncy check.
First : What is this exception
Second: I need to make the variable "read" public. How can i do that?
thx.
 
you can catch exeption in try block like:

VB.NET:
try
'your code
catch ex as exeption
'your code if first fails
finnaly
'your code
end try
declare variable as public:

Public SomeVariable As String = "Something"
or
Public Shared SomeVariable As String = "Something"
 
Thx man.
But to declare this variable as public, i have to declare it outside the button_click procedure. Look at this and see if you can help me:(we are talking about the variable x):
VB.NET:
dim h as string
if checkbox1.checked=true then
h=textbox1.text
else if checkbox2.checked=true then
h=textbox2.text
end if
dim x as system.io.stream = new system.io.filestream(h,filemode.open,fileaccess.read)
so the path is variable and i can't put all this before the procedure!!:confused:
 
VB.NET:
Public x as system.io.stream 
Dim h As String
 
Private Button_Click (...) Handles Button.Click
if checkbox1.checked=true then
h=textbox1.text
else if checkbox2.checked=true then
h=textbox2.text
end if
x = new system.io.filestream(h,filemode.open,fileaccess.re ad)
End Sub
I don't know what is the problem. I probably don't understand what you are trying to say. Hope this helps.
 
Research variable scope. You probably don't need to make the variable Public as Public variables are accesible from outside the class. It would most likely suffice to make the variable Private. A Private variable would still be a class level variable, accessible everywhere in the class but not elsewhere. It's best to keep the variable's scope as narrow as possible.
 
Back
Top