Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Does VB have SYMBOLIC CONSTANTS similar to C/C++

Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as
used in the C Language. For Example, in C:

#define AAA sheet4.cells(35,6)

Sub SomeSub()

AAA = "xyz"

end sub

The compiler encounters the "#define" directive and thereafter replaces all
occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up compiling
the statement:

sheet4.cells(35,6) = "xyz"

thanks,

ken


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Does VB have SYMBOLIC CONSTANTS similar to C/C++


Hello Ken,

No, there isn't.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=514163

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Does VB have SYMBOLIC CONSTANTS similar to C/C++

No, afraid it doesn't. But this may be enough for you

Dim AAA As Range

Sub Main
Set AAA = sheet4.cells(35,6)
...
SomeSub
...
End Sub

Sub SomeSub()
AAA = "xyz"
End Sub

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Ken Soenen" wrote in message
...
Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as
used in the C Language. For Example, in C:

#define AAA sheet4.cells(35,6)

Sub SomeSub()

AAA = "xyz"

end sub

The compiler encounters the "#define" directive and thereafter replaces

all
occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up

compiling
the statement:

sheet4.cells(35,6) = "xyz"

thanks,

ken




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Does VB have SYMBOLIC CONSTANTS similar to C/C++

ken,

Sounds very similar to declaring a "constant".
Constants can only be declared as one of the following data types: _
Boolean, Byte, Integer, Long, Currency, Single, Double, Date, String, or Variant.
A constant can be declared in a Module or within a Sub routine.

The code would look something like...
Public Const LONG_AGE As Long = 99

Note however that objects are not one of the data types.
So for a range object (cells) you would instead use a variable by...
1. declaring its data type
2. assigning the range to the variable using a "Set" statement.

Dim objRange as Excel.Range
Set objRange = Worksheets("Sheet4").Cells(35, 6)

Then you can use objRange when you assign a value to
those excel cells...
objRange.Value = "xyz"
The Range object has several properties.
The Value property is the default property.
However, it is good practice to always specify the property that is being used.

Regards,
Jim Cone
San Francisco, USA



"Ken Soenen" wrote in message...
Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as
used in the C Language. For Example, in C:
#define AAA sheet4.cells(35,6)

Sub SomeSub()
AAA = "xyz"
end sub

The compiler encounters the "#define" directive and thereafter replaces all
occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up compiling
the statement:
sheet4.cells(35,6) = "xyz"
thanks,
ken
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Does VB have SYMBOLIC CONSTANTS similar to C/C++

Ken,

No, VBA doesn't have what you are looking for. You can, however,
use Property Get procedures in your module. E.g.,

Property Get AAA() As Range
Set AAA = Range("A1")
End Property



Sub BBB()
AAA.Value = 123
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken Soenen" wrote in message
...
Is there anything in Visual Basic that is similar to SYMBOLIC
CONSTANTS as used in the C Language. For Example, in C:

#define AAA sheet4.cells(35,6)

Sub SomeSub()

AAA = "xyz"

end sub

The compiler encounters the "#define" directive and thereafter
replaces all occurrences of "AAA" with "sheet4.cells(35,6)". So
it then ends up compiling the statement:

sheet4.cells(35,6) = "xyz"

thanks,

ken






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Does VB have SYMBOLIC CONSTANTS similar to C/C++

Thanks for all your replies. The suggestions for using the SET keyword and
RANGE gives me what I'm looking for. Which is using a "descriptive" name
instead of the cell location.

thanks,
ken

"Ken Soenen" wrote in message
...
Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as
used in the C Language. For Example, in C:

#define AAA sheet4.cells(35,6)

Sub SomeSub()

AAA = "xyz"

end sub

The compiler encounters the "#define" directive and thereafter replaces
all occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up
compiling the statement:

sheet4.cells(35,6) = "xyz"

thanks,

ken




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
How can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 temp Excel Worksheet Functions 2 December 24th 07 10:45 PM
Better example I hope how can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 temp Excel Discussion (Misc queries) 4 December 24th 07 02:21 AM
Better example I hope how can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 temp Excel Worksheet Functions 4 December 24th 07 02:21 AM
How can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 temp Excel Discussion (Misc queries) 2 December 14th 07 07:36 PM
How can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 temp Excel Worksheet Functions 2 December 14th 07 07:36 PM


All times are GMT +1. The time now is 02:44 PM.

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

About Us

"It's about Microsoft Excel"