Labels again. Sorry

1478
9
07-24-2012 12:33 PM
AndrewSmith
New Contributor III
I have this experssion
Function FindLabel ( [FCODE], [ELEVATION]  )
  if (  [FCODE] = HA90000000 ) then
     FindLabel = [ELEVATION]
end if
End Function

it works, but it does not label the evelvation. it is just blank. both on the verify, and when I hi ok. it does not lable the number inthe elevaction such as 200, 100, 300, etc... I used the info tool and my attributes table to verify the evelavtion have numbers, but nothing is labeled. Can some one help and see what I did wrong here.:confused:
Tags (2)
0 Kudos
9 Replies
DonovanCameron
Occasional Contributor II
I think it's just a small syntax error.

[LEFT]Function FindLabel ( [FCODE], [ELEVATION] )
  if ( [FCODE] = "HA90000000" ) then
    FindLabel = [ELEVATION] 
  end if
End Function[/LEFT]


Because the value of [FCODE] is a string, it needs to be enclosed in double quotes.
0 Kudos
nimitz
by
New Contributor III
I'm having the same problem.
Function AnValue ( [LOCID] , [Silica] )
  if ( [Silica] > 0 )
then
  AnValue = [LOCID]
  end if 
End Function


This is frustrating. The LOCID field is a text field, and silica is a short int. I tried to put the LOCID in quotes, but no go.

Thanks for any help,

Randy
0 Kudos
T__WayneWhitley
Frequent Contributor
Try replacing 'AnValue' with 'FindLabel'.
Otherwise, looks good....maybe move 'then' up onto the same line with 'if', but probably doesn't matter:

if ( [Silica] > 0 ) then


Correction - both seem to matter, name of the function and 'if-then' on same line.
0 Kudos
nimitz
by
New Contributor III
no go. I tried this:
Function FindLabel ( [LOCID] , [SILICA] )
  if ( ["SILICA"] > 0 ) then
Findlabel = [LOCID] 
  end if
End Function


The quotes that are around SILICA should have done the trick...
0 Kudos
T__WayneWhitley
Frequent Contributor
First of all, that is not how you convert to string - anyway you don't need string for testing a numeric field.
Also both FindLabel vars must be same case (do not mix case).
[EDIT:  Actually doesn't appear to be case-sensitive, but still bad practice]

I'd say make sure your fields are what you think; if so, the VBScript expression should work (also check that you're not dealing with any null values, just in case):

Function FindLabel ([LOCID],[SILICA])
  if ([SILICA] > 0) then
     FindLabel = [LOCID] 
  end if
End Function



One final thing--
If trying to test for labeling what is not equal to zero, then use:

if ([SILICA] <> 0) then


...details matter!
0 Kudos
nimitz
by
New Contributor III
Wayne, thanks for the help.

I only am dealing with 4 records, but I want' to nail this down, b/c I know that I got some data that could be dozens of records.

I've changed the field "silica" several times:I've made it a short a double and with the code just like the example in the help.

Still no go.
0 Kudos
T__WayneWhitley
Frequent Contributor
Probably just a misunderstanding - what exactly is the label function doing, what do you want it to do, and are there any errors reported back?

Did you make the substitution, instead of:

>

use:

<>

Check your fields and field values.  With a dataset so small, why don't you just attach it?
0 Kudos
nimitz
by
New Contributor III
I have some wells that have a detection of Silica and I have some that have a zero - either their was no silica or we didn't test it.

I would like the labels to display if there is a value at the well. If there is a zero, I don't want it to display zero, I just want it to be blank.



Here is a screen shot of where put the labels in by hand: I converted the labels to anno and just typed in the values I needed.
[ATTACH=CONFIG]18660[/ATTACH]

Thanks,
0 Kudos
T__WayneWhitley
Frequent Contributor
OK, then Ken Buja at your other thread is correct ---- except things got confused about which operator '>' or '<>' to use.

You should be using <> for 'not equal to'...  or '>' which means 'greater than' should work too - thing is, you may be missing this, are you displaying rounded values?...... I probably shouldn't post any more code and let you figure it out, and exercise the proper care - definitely this should work, and you should thank Ken for this:

Function FindLabel ( [LOCID] , [Silica]  )
  if ( [Silica] <> 0) then 
    FindLabel = [LOCID] & vbNewLine & [Silica] 
  else
    FindLabel = [LOCID]
  end if 
End Function
0 Kudos