Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Excel 2003 to Excel 2007 Question Mr. Panasonic Excel Worksheet Functions 0 December 15th 08 06:16 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM
Statistical Excel Function Question within Excel 2000... Drew H Excel Worksheet Functions 3 October 31st 04 06:55 PM
Excel 2000 versus Excel 2002 question Carla[_4_] Excel Programming 1 July 22nd 04 06:54 PM


All times are GMT +1. The time now is 12:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"