Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel vb question
Greetings,
I am writing some vb code in excel (version that comes with Office 2000). I am a programmer, and really haven't dealt with excel before. If I define a public variable on the workbook, can I initialize it at definition ? ie, public test as integer init 0 How do I initialize the variable (or determine it needs initialization) before using it ? thanks, -D |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel vb question
Darryl,
You can use a constant Public Const test As Integer = 0 of course, that stops you changing it later. -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Greetings, I am writing some vb code in excel (version that comes with Office 2000). I am a programmer, and really haven't dealt with excel before. If I define a public variable on the workbook, can I initialize it at definition ? ie, public test as integer init 0 How do I initialize the variable (or determine it needs initialization) before using it ? thanks, -D |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel vb question
Sorry I wasn't very clear.
I need it to be a variable as I'm going to increment it as I do certain things. "Bob Phillips" wrote in message ... Darryl, You can use a constant Public Const test As Integer = 0 of course, that stops you changing it later. -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Greetings, I am writing some vb code in excel (version that comes with Office 2000). I am a programmer, and really haven't dealt with excel before. If I define a public variable on the workbook, can I initialize it at definition ? ie, public test as integer init 0 How do I initialize the variable (or determine it needs initialization) before using it ? thanks, -D |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel vb question
Then you can't initialise is as you thought. What you can do is something
like this Public test As Variant Sub myCode() If IsEmpty(test) Then test = 0 End If 'rest of code End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Sorry I wasn't very clear. I need it to be a variable as I'm going to increment it as I do certain things. "Bob Phillips" wrote in message ... Darryl, You can use a constant Public Const test As Integer = 0 of course, that stops you changing it later. -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Greetings, I am writing some vb code in excel (version that comes with Office 2000). I am a programmer, and really haven't dealt with excel before. If I define a public variable on the workbook, can I initialize it at definition ? ie, public test as integer init 0 How do I initialize the variable (or determine it needs initialization) before using it ? thanks, -D |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel vb question
OK.
If I define a variable that is integer, is it automatically initialized to 0 or can it be any old garbage ? I'm going to keep adding 1 to the variable each time a button is pressed and I don't want to do something like test = test +1 if test is garbage. thanks, D I assume that IsEmpty only works with variant type variables ? "Bob Phillips" wrote in message ... Then you can't initialise is as you thought. What you can do is something like this Public test As Variant Sub myCode() If IsEmpty(test) Then test = 0 End If 'rest of code End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Sorry I wasn't very clear. I need it to be a variable as I'm going to increment it as I do certain things. "Bob Phillips" wrote in message ... Darryl, You can use a constant Public Const test As Integer = 0 of course, that stops you changing it later. -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Greetings, I am writing some vb code in excel (version that comes with Office 2000). I am a programmer, and really haven't dealt with excel before. If I define a public variable on the workbook, can I initialize it at definition ? ie, public test as integer init 0 How do I initialize the variable (or determine it needs initialization) before using it ? thanks, -D |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel vb question
Yes, an integer initialises to 0 every time.
-- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... OK. If I define a variable that is integer, is it automatically initialized to 0 or can it be any old garbage ? I'm going to keep adding 1 to the variable each time a button is pressed and I don't want to do something like test = test +1 if test is garbage. thanks, D I assume that IsEmpty only works with variant type variables ? "Bob Phillips" wrote in message ... Then you can't initialise is as you thought. What you can do is something like this Public test As Variant Sub myCode() If IsEmpty(test) Then test = 0 End If 'rest of code End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Sorry I wasn't very clear. I need it to be a variable as I'm going to increment it as I do certain things. "Bob Phillips" wrote in message ... Darryl, You can use a constant Public Const test As Integer = 0 of course, that stops you changing it later. -- HTH RP (remove nothere from the email address if mailing direct) "Darryl" wrote in message ... Greetings, I am writing some vb code in excel (version that comes with Office 2000). I am a programmer, and really haven't dealt with excel before. If I define a public variable on the workbook, can I initialize it at definition ? ie, public test as integer init 0 How do I initialize the variable (or determine it needs initialization) before using it ? thanks, -D |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 Macro/VB Question DDE Question | Excel Worksheet Functions | |||
Excel 2003 to Excel 2007 Question | Excel Worksheet Functions | |||
The question is an excel question that I need to figure out howto do in excel. | Excel Worksheet Functions | |||
Statistical Excel Function Question within Excel 2000... | Excel Worksheet Functions | |||
Excel 2000 versus Excel 2002 question | Excel Programming |