Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's equivalent in VB.NET for VFP's #DEFINE in/and .H file?

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
566
0
16
US
Colleagues,

Being working in VFP for so long (1997-2019), and last time working in VB 13+ years ago, I cannot find if there is in VB.NET something similar to VFP's .H file with all those #DEFINE statements.
Essentially, I need to define an array in header/resource file, and #INCLUDE (or just include) this file into the project. This array is to be used to optimize the code in VB .NET by replacing excessive If-ElseIf-... with For-Next cycle.
AHWBGA!

Regards,

Ilya
 
Precompiler directives are very common in any language, and the file extension also usually is .h

But you gotta tell me how you define an array via #define in VFP, you define constants, the names of them get replaced with the values, essentially. In VB.NET this is made with the preprocessor directive #CONST instead of #Define. You write that as #CONST NAME='value', or #CONST Answer=42 instead of the #DEFINE syntax that does not have the = operator.

But I think you look for something else.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hi Olaf,
"how you define an array via #define in VFP" - good question! :)
Do not remember exactly how, but I saw it in yet VFP3b, IMS. My then "partner in crime" (fellow P/A) had it in a program written in FPD2.5, transferred it to VFP3, and it worked.
But then again: I might remembered the idea, not the execution of that latter...
Anyway, thank you for your tip, colleague!
I wonder if VB .NET would take #CONST String [] Offices = {"CHI","ATL","TRR","HII","MLW"}...

Regards,

Ilya
 
I think you look for an Enumeration.

Code:
Public Enum Days
  Sunday
  Monday
  Tuesday
  Wednesday
  Thursday
  Friday
  Saturday
End Enum

Dim items As Array
items = System.Enum.GetValues(GetType(Days))
Dim item As String
For Each item In items
    MsgBox(item)
Next

Bye, Olaf.

Olaf Doschke Software Engineering
 
Enumeration... The thought occurred to me also, but got no traction (dunno why).
Thank you for setting me straight, colleague!


Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top