Hello Guest it is March 28, 2024, 04:26:06 PM

Author Topic: The equal sign in VB  (Read 3747 times)

0 Members and 1 Guest are viewing this topic.

Offline PSG

*
  •  21 21
    • View Profile
The equal sign in VB
« on: January 06, 2010, 05:31:15 PM »

Please bare with me. I am trying to learn VB so the some of the questions may seem silly or stupid. Up until now, the Cypress VB doc is only partially helpful. I seem to have better luck by reading actual known/working scripts and deciphering the operation.

The questions I have (today) are in regards to "DIM" and "=".

1. If I where to assign values/names using the "=", can I therefore just use that name in script that follows instead?
2. What does "DIM" do?

Again not trying to ask silly/stupid questions. Just trying to get a handle on VB.

TIA

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: The equal sign in VB
« Reply #1 on: January 06, 2010, 08:07:50 PM »
1) I think yes, but am not clear what you mean. Like this?

a=1
b = a+2

2) I better let a programmer explain that. Or you can try reading this.
http://msdn.microsoft.com/en-us/library/7ee5a7s1(VS.80).aspx
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: The equal sign in VB
« Reply #2 on: January 07, 2010, 07:41:16 AM »
dim is short for dimension. Originally it was only used to specify arrays and later became used for scalar values as well. Its just BASICs syntax for defining a variable.

so DIM x as integer tells the basic interpreter to:

allocate (dimension) the required number of bytes on the stack to be used as storage for an integer value and point the symbol table entry for the name x in the current stack frame at it. (well you did ask)  ;D

Ian

Offline PSG

*
  •  21 21
    • View Profile
Re: The equal sign in VB
« Reply #3 on: January 07, 2010, 12:22:34 PM »

Thank you to both of you. You are right Ian, I did ask  ;D . It must be some sort of insanity that sets in after a while  ;D

I have always known the usefulness of custom macros in Mach but I am really starting to see the real power that is available. The questions come from an auto-zero script posted by another Mach user. I already have a zero script that works well so I am not in a bind to make one work but in reading this script I see the "DIM" and of course the "equals" sign. I was always under the impression that in order write scripts for Mach that I would need to memorize an endless list of commands and oem codes. In reading this script, it gives the feel of the old "basic" (Commadore64 stuff - the last time I ever wrote a piece of code  :))

If you guys or someone can help me define the attached script, I think it will be a great help in understanding.

TIA