vbscript for NOT displaying zero's in attribute field for labels

1533
11
Jump to solution
10-23-2012 07:53 AM
nimitz
by
Occasional Contributor
Hey all,
I'm trying to label some wells with their ID and analyte value,  but if the well has a zero I don't need it labeled. Could anyone take a look at what I've got so far? I keep getting an error, but I can't seem to figure it out.
The function is calling our 'Silica', and I"m wondering if this field needs to be all uppercase?
Function AnValue ( [LOCID] , [Silica] )   if ( [Silica] > 0 then   AnValue = [Silica]   end if  End Function

Any help is appreciated,

Randy
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
From your other thread, are you looking for something like this?

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

View solution in original post

0 Kudos
11 Replies
nimitz
by
Occasional Contributor
I'm wondering if the SILICA field needs to be a certain type? I have it has a short integer now with 4 as precision.
0 Kudos
KenBuja
MVP Esteemed Contributor
You code was missing a parenthesis. This code works with a numeric field with decimals


Function FindLabel ( [LOCID] , [Silica]  )
  if ( [Silica] > 0) then
    FindLabel =[Silica]
  end if
End Function
0 Kudos
nimitz
by
Occasional Contributor
yeah, I found that. still no go.
0 Kudos
KenBuja
MVP Esteemed Contributor
This is how it works for me

[ATTACH=CONFIG]18659[/ATTACH]
0 Kudos
nimitz
by
Occasional Contributor
yeah, that's what I got.
[ATTACH=CONFIG]18662[/ATTACH]

thanks,
0 Kudos
KenBuja
MVP Esteemed Contributor
Why do you have two SILICA fields? Could that be an issue?
0 Kudos
nimitz
by
Occasional Contributor
ha ha! good catch ken. I THINK what happened is when I was experimenting with adding different fields, the SILICA field was entered in a couple of times. Well, when I deleted the fields, I didn't "refresh" the label expression dialog box. So, I removed the shape file and added it back in, and VOILA!

However, the function is not labeling the other well sites that have a zero. hmmm
0 Kudos
KenBuja
MVP Esteemed Contributor
However, the function is not labeling the other well sites that have a zero. hmmm


Now I'm not sure what your objective is. I thought you didn't want the well sites with a zero to be labeled.
0 Kudos
KenBuja
MVP Esteemed Contributor
From your other thread, are you looking for something like this?

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