Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning even value to define scale

Status
Not open for further replies.

accessuserit

Programmer
Nov 10, 2001
29
IT
I need help to define my value of maxscale and minscale of a graph. My request is that the number are forced to even value.
My formula now define the min and max value of scale:
------------------------------------------------------
Private Sub Form_load()
Dim valoremax As Variant
Dim valoremin As Variant
Dim diff As Variant
Dim scala As Integer
diff = valoremax - valomin
If scala <= 4 Then
scala = 2
End If
If diff < 10 Then
valoremin = [MinDiMIN] - 2
End If
If diff >= 10 Then
valoremin = [MinDiMIN] * 0.96
End If
If diff < 10 Then
valoremax = [MaxDiMAX] + 2
End If
If diff >= 10 Then
valoremax = [MaxDiMAX] * 1.04
End If
Me![Mychart].Axes(1).minimumscale = valoremin
Me![Mychart].Axes(1).maximumscale = valoremax
Me![Mychart].Axes(1).MinorUnit = scala
Me![Mychart].Axes(1).MajorUnit = scala
Me![Mychart].Axes(2).minimumscale = valoremin
Me![Mychart].Axes(2).maximumscale = valoremax
Me![Mychart].Axes(2).MinorUnit = scala
Me![Mychart].Axes(2).MajorUnit = scala
On Error Resume Next
End Sub
------------------------------------------

The value valoremin and valoremax in certain record are odd, and the unit of the graph are odd, is noto good.

Thanks for help!!!

Paul
 
Paul,

You can test if the value is odd, and if it is then increment the value by +1 or -1. Is that what you want to do?

GGleason
 
I have found the solution!
I check if valoremin or valoremax are odd, and after add or subtract 1 to value. It work perfectly.
-------------------------------------------
If valoremin Mod 2 = 1 Then
valoremin = valoremin - 1
End If

If valoremax Mod 2 = 1 Then
valoremax = valoremax + 1
End If
-------------------------------------------
Thanks GGleason
by Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top