I have variables in my procedure x,y,z. These are integers.
i want to place them in an array as Array(x,y,z) and determine which is the greatest value.
How can I identify the highest value in the array?
Thanks.
Janie
Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another.
Any content of an adult theme or inappropriate to a community web site.
Any image, link, or discussion of nudity.
Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect.
Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software.
Unsolicited bulk mail or bulk advertising.
Any link to or advocacy of virus, spyware, malware, or phishing sites.
Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct.
Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.
Sub aaa()
Dim x As Long, y As Long, z As Long, v1 As Variant
Dim max As Long, i As Long, v As Variant, idex as Long
z = Int(Rnd() * 1000 + 1)
y = Int(Rnd() * 1000 + 1)
x = Int(Rnd() * 1000 + 1)
'Debug.Print x, y, z
v = Array(x, y, z)
v1 = Array("x", "y", "z")
max = -10000
For i = LBound(v) To UBound(v)
If v(i) > max Then
max = v(i)
idex = i
End If
MsgBox "max of x, y, z is " & v1(idex) & "=" & max
End Sub
Regards,
Tom Ogilvy
Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another.
Any content of an adult theme or inappropriate to a community web site.
Any image, link, or discussion of nudity.
Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect.
Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software.
Unsolicited bulk mail or bulk advertising.
Any link to or advocacy of virus, spyware, malware, or phishing sites.
Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct.
Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.
I think we need to clarify how you are going to set up your array. If you declare the array as:
Dim myArray(1 to X, 1 to Y, 1 to Z) then you end up with an array that has all of the probably out in the 3rd dimension.
If you were to dimension it this way:
Dim myArray(1 to 1000, 1 to 3)
Then that sets up to hold up to 1000 entries (kind of like 1000 rows) and data into 3 other elements, like the columns on a worksheet.
So your X values could go into myArray(rNum, 1), and
your Y values could go into myArray(rNum, 2), and
your Z values could go into myArray(rNum, 3).
where rNum is a number from 1 to 1000.
Actually, to make it more flexible and potentially a dynamic array you can extend as needed:
Dim myArray() As Integer
then later in the program, before you start filling it up, you initialize it something like this:
Redim myArray(1 to 3,1 to 1)
Then some more fancy footwork in VBA involving Redim Preserve() will allow you to expand the ,1 to 1) part of it as needed.
But regardless, we do need to know how you're going to reference things in your Array(). It might be as simple as
Dim Array(1 to 3) with X in 1, Y in 2 and Z in 3, but we need to know.
I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein
Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another.
Any content of an adult theme or inappropriate to a community web site.
Any image, link, or discussion of nudity.
Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect.
Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software.
Unsolicited bulk mail or bulk advertising.
Any link to or advocacy of virus, spyware, malware, or phishing sites.
Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct.
Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.