Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Conditioning on ACTIVE REPORT


PcRobotic
 Share

Recommended Posts

Hello everyone,

   I'm very new in ACTIVE REPORT and I don't know where to start with writing "IF, ELSE" conditioning.  I hope you guys can point me to the right direction. 

 

Suppose I would like to make like this:

 

IF TIP ANGLE>0 then APPEAR with RED color

IF TIP ANGLE = 0 or N/A then DISAPPEAR or DO NOT SHOW.

 

Tool Sheet Screenshot:

https://drive.google.com/file/d/0B4UZsmondnEza2owUC1sanpsRUk/view?usp=sharing

 

Active Report Screenshot:

https://drive.google.com/file/d/0B4UZsmondnEzQXZENllURWtRLWM/view?usp=sharing

 

Here is what I think it would be but I only can make it RED COLOR and I cannot make it disappear. Please see details below.  Thank you.

 

==========================

If (IsNumeric(txtTIP_ANGLE1.Text)) Then
 
    If (CDbl(txtTIP_ANGLE1.Text) > 0) Then
 
        txtTIP_ANGLE1.Forecolor = Color.Red
 
        Label6.Forecolor = Color.Red
 
    Else
 
        txtTIP_ANGLE1.Forecolor = Color.LightGray
 
        txtTIP_ANGLE1.Text = "0"
 
       Label6.Forecolor = Color.LightGray
 
End If
 
 
  • Like 1
Link to comment
Share on other sites

 

Try something like:

 

int TipAngle;
int.TryParse(txtLabelTipAngle.Text, out TipAngle);

// TipAngle will be 0 if TryParse failed
If (TipAngle > 0) {
    txtLabelTipAngle.Forecolor = Color.Red
} else {
    txtLabelTipAngle.Visible = false
}

Hi Themachinist,

   I tried your codes and it had so many error.  Do you think I should add some new codes into my existing codes?

 

If (IsNumeric(txtTIP_ANGLE1.Text)) Then  =========> It's working now
 
   If (CDbl(txtTIP_ANGLE1.Text) > 0) Then   =========> It's working now
 
      txtTIP_ANGLE1.Forecolor = Color.Red  =========> It's working now
 
     Label6.Forecolor = Color.Red                   =========> It's working now
 
End If                                                               =========> It's working now
 
If (IsNumeric(txtTIP_ANGLE1.Text) <= 0 ) Then    =========> It's NOT working now
 
    If (CDbl(txtTIP_ANGLE1.Text) <= 0) Then        =========> It's NOT working now
 
            txtTIP_ANGLE1.Text = "0"                       =========> It's NOT working now
 
            txtTIP_ANGLE1.Forecolor = Color.Blue  =========> It's NOT working now
 
          Label6.Forecolor = Color.Blue                  =========> It's NOT working now
 
End If
Link to comment
Share on other sites

 

Try something like:

 

int TipAngle;
int.TryParse(txtLabelTipAngle.Text, out TipAngle);

// TipAngle will be 0 if TryParse failed
If (TipAngle > 0) {
    txtLabelTipAngle.Forecolor = Color.Red
} else {
    txtLabelTipAngle.Visible = false
}

Hi TheMachinist,

   First of all, thank you for your help.  After 2 days of figure things out.  This is what I came up with and it is perfect as I wanted.  I hope that if someone who has the same problem as I have, this is "IT" to write conditioning IF, ELSE...

 

 

 

======================

 

If (IsNumeric(txtTIP_ANGLE1.Text) = 0) Then
 
      txtTIP_ANGLE1.Text = "0"
 
     End If
 
End If
 
If (IsNumeric(txtTIP_ANGLE1.Text)) Then
 
     If (CDbl(txtTIP_ANGLE1.Text) > 0) Then
 
     txtTIP_ANGLE1.Forecolor = Color.Black
 
    DEG.Forecolor = Color.Black
 
   Else
 
     txtTIP_ANGLE1.Forecolor = Color.LightGray
 
 
     DEG.Forecolor = Color.LightGray
 
End If
  • Like 1
Link to comment
Share on other sites

Hi PcRobotic,

 

Sorry I was not able to get back to you quickly after you asked me to make the additional changes to your report code.

 

Instead of:

 

If (IsNumeric(txtTIP_ANGLE1.Text)) Then
 
     If (CDbl(txtTIP_ANGLE1.Text) > 0) Then
 
     txtTIP_ANGLE1.Forecolor = Color.Black
 
    DEG.Forecolor = Color.Black
 
Else
 
     txtTIP_ANGLE1.Forecolor = Color.LightGray
 
     DEG.Forecolor = Color.LightGray
 
End If
 
Try:
 
If (IsNumeric(txtTIP_ANGLE1.Text)) Then
 
     If (CDbl(txtTIP_ANGLE1.Text) > 0) Then
 
     txtTIP_ANGLE1.Forecolor = Color.Black
 
    DEG.Forecolor = Color.Black
 
    txtTIP_ANGLE1.Visible = True
 
    DEG.Visible = True
 
Else
 
    txtTIP_ANGLE1.Visible = False
 
    DEG.Visible = False
 
End If
  • Like 2
Link to comment
Share on other sites

Here I tested this in AR6:

 

 

Sub ActiveReport_ReportStart
    Dim TipAngle as Integer
 
    ' TryParse will set TipAngle to 0 if it fails for some reason,e.g. Label1.Text not being a number or being set to null
    System.Int32.TryParse(Label1.Text, TipAngle)
 
    ' Because TryParse will set TipAngle to zero in all of our undesired cases we can reduce our logic to a single if statement, either the tip angle is greater than 0 or we want to hide the label
    If (TipAngle > 0) Then
        Label1.ForeColor = Color.Red
    Else
        Label1.Visible = false
    End If
End Sub
  • Like 2
Link to comment
Share on other sites

 

Here I tested this in AR6:

Sub ActiveReport_ReportStart
    Dim TipAngle as Integer
 
    ' TryParse will set TipAngle to 0 if it fails for some reason,e.g. Label1.Text not being a number or being set to null
    System.Int32.TryParse(Label1.Text, TipAngle)
 
    ' Because TryParse will set TipAngle to zero in all of our undesired cases we can reduce our logic to a single if statement, either the tip angle is greater than 0 or we want to hide the label
    If (TipAngle > 0) Then
        Label1.ForeColor = Color.Red
    Else
        Label1.Visible = false
    End If
End Sub

 

Thank you for all of your help TheMachinist, it really helped.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...