What's new

.NET [VB.NET] Algorithm Help! :(

  • Thread starter Revvv
  • Start date
  • Views 335
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
So I'm trying to pick from a selections of variables depending on their value.

The variables and their values(to start off with).
Code:
Dim array1 As Integer = Integer.Parse(array1.Count - 1) '''' = 5
Dim array2 As Integer = Integer.Parse(array2.Count - 1) '''' = 4
Dim array3 As Integer = Integer.Parse(array3.Count - 1) '''' = 4
Dim array4 As Integer = Integer.Parse(array4.Count - 1) '''' = 4

So from the variables I have now I need to check them all and then find which one to add onto. So with the variables values I have set I need to add onto the array2. But for some reason I can't seem to do it. I've tried doing alot of things and this is what I have come up with so far however it is just choosing array1 everytime :frown:

Code:
If array1 - array2 = 1 Then
            array2.Add("")
            Return "1"
        ElseIf array2 - array3 = 1 Then
            array3.Add("")
            Return "3"
        ElseIf array3 - array4 = 1 Then
            array4.Add("")
            Return "4"
        ElseIf array1 = array4 Then
            array1.Add("")
            Return "0"
        Else
            Return "4"
        End If

Does anyone know how I could do this? :|
 
ActionScript

ActionScript

XG R4PiDzZ
Grizzled Veteran Programmer Modder
Messages
2,649
Reaction score
1,405
Points
475
So I'm trying to pick from a selections of variables depending on their value.

The variables and their values(to start off with).
Code:
Dim array1 As Integer = Integer.Parse(array1.Count - 1) '''' = 5
Dim array2 As Integer = Integer.Parse(array2.Count - 1) '''' = 4
Dim array3 As Integer = Integer.Parse(array3.Count - 1) '''' = 4
Dim array4 As Integer = Integer.Parse(array4.Count - 1) '''' = 4

So from the variables I have now I need to check them all and then find which one to add onto. So with the variables values I have set I need to add onto the array2. But for some reason I can't seem to do it. I've tried doing alot of things and this is what I have come up with so far however it is just choosing array1 everytime :frown:

Code:
If array1 - array2 = 1 Then
            array2.Add("")
            Return "1"
        ElseIf array2 - array3 = 1 Then
            array3.Add("")
            Return "3"
        ElseIf array3 - array4 = 1 Then
            array4.Add("")
            Return "4"
        ElseIf array1 = array4 Then
            array1.Add("")
            Return "0"
        Else
            Return "4"
        End If

Does anyone know how I could do this? :|


I have no idea what you are attempting. Why don't you use List's?
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,476
Reaction score
3,423
Points
1,042
You see, this is why C# is better, people can understand what you're doing.
 
AceInfinity

AceInfinity

Enthusiast
Messages
146
Reaction score
39
Points
85
I would suggest a Dictionary here instead of a List.
 

Similar threads

Top Bottom
Login
Register