Loading ...
Sorry, an error occurred while loading the content.
 

Re: How to set IF-THEN condition in VB

Expand Messages
  • ftkalcevic
    ... Which bit? The if-then-else part of what I gave was correct VB syntax. I see in your sample, you use Code(), so I can see you know how to do that.
    Message 1 of 5 , Jan 31, 2010
      > Correctly, but I don't know how to do this properly in VB.

      Which bit? The if-then-else part of what I gave was correct VB syntax. I see in your sample, you use Code(), so I can see you know how to do that. Anything in particular?



      >
      > Thanks,
      > Tom
      >
      > 2010/1/31 ftkalcevic <frank@...>
      >
      > >
      > >
      > > Do you mean this?
      > >
      > >
      > > If Z > 0.5 then
      > > code ("G1 Z5") and repeat macro from line 20 (re-measuring)
      > > else If Z < -0.5 then
      > > red LED is flashing
      > > else If Z<0.5 and Z>-0.5 then
      > > green led is flashing.
      > > end if
      > >
      > >
      > > --- In mach1mach2cnc@yahoogroups.com <mach1mach2cnc%40yahoogroups.com>,
      > > Toma¾ Kuhl <kuhl.tomaz@> wrote:
      > > >
      > > > Hi All,
      > > >
      > > > I'm learning VB by doing and here's a lack of my knowledge again.
      > > > Down bellow is a measuring (probing) macro and it works good.
      > > > Macro result is a value of Z position in DRO. Now I don't know how
      > > > to set triple IF-THEN condition to execute further action:
      > > >
      > > > If Z > 0.5 then code ("G1 Z5") and repeat macro from line 20
      > > (re-measuring)
      > > > If Z < -0.5 then red LED is flashing
      > > > If Z<0.5 and Z>-0.5 then green led is flashing.
      > > >
      > > > Any idea would be highly appreciated.
      > > >
      > > > Many thanks in advance!
      > > > Tom
      > > >
      > > >
      > > >
      > > > ----------------------------------------------------------
      > > > OffsetDRO = 1100
      > > > RefPosOffset = GetUserDRO (OffsetDRO)
      > > > DoOEMButton(1024) 'Referencing
      > > > While IsMoving()
      > > > Sleep 100
      > > > Wend
      > > > Code ("G53 G0 Z-" & RefPosOffset)
      > > > While IsMoving()
      > > > Sleep 100
      > > > Wend
      > > > DoOEMButton(1010)
      > > > While IsMoving()
      > > > Sleep 100
      > > > Wend
      > > > Code ("G53 G0 Z-2.71")
      > > > While IsMoving()
      > > > Sleep 100
      > > > Wend
      > > > Rem VBScript To probe In the z axis
      > > > If GetOemLed (825) <> 0 Then
      > > > Code "(Already measured)"
      > > > Else
      > > > CurrentFeed = GetOemDRO(818)
      > > > Code "F50"
      > > > Rem Probe In the z direction
      > > > ZNew = GetDro(2) - 10
      > > > Code "G31Z" &ZNew
      > > > While IsMoving()
      > > > Wend
      > > > ZNew = GetVar(2002)
      > > > Code "G0 Z" &ZNew
      > > > While IsMoving ()
      > > > Wend
      > > > Code "F" &CurrentFeed
      > > > End If
      > > >
      > > >
      > > > [Non-text portions of this message have been removed]
      > > >
      > >
      > >
      > >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    • Tomaž Kuhl
      Hi Frank, Macro is working good, I m learning VB by doing on my machine and I still having a lot of problems and a lot to learn. Thanks, Tom 2010/2/1
      Message 2 of 5 , Feb 1, 2010
        Hi Frank,

        Macro is working good, I'm learning VB by doing on my machine and I still
        having a lot
        of problems and a lot to learn.

        Thanks,
        Tom

        2010/2/1 ftkalcevic <frank@...>

        >
        >
        > > Correctly, but I don't know how to do this properly in VB.
        >
        > Which bit? The if-then-else part of what I gave was correct VB syntax. I
        > see in your sample, you use Code(), so I can see you know how to do that.
        > Anything in particular?
        >
        > >
        > > Thanks,
        > > Tom
        > >
        > > 2010/1/31 ftkalcevic <frank@...>
        >
        > >
        > > >
        > > >
        > > > Do you mean this?
        > > >
        > > >
        > > > If Z > 0.5 then
        > > > code ("G1 Z5") and repeat macro from line 20 (re-measuring)
        > > > else If Z < -0.5 then
        > > > red LED is flashing
        > > > else If Z<0.5 and Z>-0.5 then
        > > > green led is flashing.
        > > > end if
        > > >
        > > >
        > > > --- In mach1mach2cnc@yahoogroups.com <mach1mach2cnc%40yahoogroups.com><mach1mach2cnc%
        > 40yahoogroups.com>,
        >
        > > > Toma� Kuhl <kuhl.tomaz@> wrote:
        > > > >
        > > > > Hi All,
        > > > >
        > > > > I'm learning VB by doing and here's a lack of my knowledge again.
        > > > > Down bellow is a measuring (probing) macro and it works good.
        > > > > Macro result is a value of Z position in DRO. Now I don't know how
        > > > > to set triple IF-THEN condition to execute further action:
        > > > >
        > > > > If Z > 0.5 then code ("G1 Z5") and repeat macro from line 20
        > > > (re-measuring)
        > > > > If Z < -0.5 then red LED is flashing
        > > > > If Z<0.5 and Z>-0.5 then green led is flashing.
        > > > >
        > > > > Any idea would be highly appreciated.
        > > > >
        > > > > Many thanks in advance!
        > > > > Tom
        > > > >
        > > > >
        > > > >
        > > > > ----------------------------------------------------------
        > > > > OffsetDRO = 1100
        > > > > RefPosOffset = GetUserDRO (OffsetDRO)
        > > > > DoOEMButton(1024) 'Referencing
        > > > > While IsMoving()
        > > > > Sleep 100
        > > > > Wend
        > > > > Code ("G53 G0 Z-" & RefPosOffset)
        > > > > While IsMoving()
        > > > > Sleep 100
        > > > > Wend
        > > > > DoOEMButton(1010)
        > > > > While IsMoving()
        > > > > Sleep 100
        > > > > Wend
        > > > > Code ("G53 G0 Z-2.71")
        > > > > While IsMoving()
        > > > > Sleep 100
        > > > > Wend
        > > > > Rem VBScript To probe In the z axis
        > > > > If GetOemLed (825) <> 0 Then
        > > > > Code "(Already measured)"
        > > > > Else
        > > > > CurrentFeed = GetOemDRO(818)
        > > > > Code "F50"
        > > > > Rem Probe In the z direction
        > > > > ZNew = GetDro(2) - 10
        > > > > Code "G31Z" &ZNew
        > > > > While IsMoving()
        > > > > Wend
        > > > > ZNew = GetVar(2002)
        > > > > Code "G0 Z" &ZNew
        > > > > While IsMoving ()
        > > > > Wend
        > > > > Code "F" &CurrentFeed
        > > > > End If
        > > > >
        > > > >
        > > > > [Non-text portions of this message have been removed]
        > > > >
        > > >
        > > >
        > > >
        > >
        > >
        > > [Non-text portions of this message have been removed]
        > >
        >
        >
        >


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.