• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

arry string compare

There are 5 string fields. The string sets will be an arry i=0 to j.
My question is how can I get the most common string set?
Do I need to use two arrys to compare the 5 strings 0-j times?
Thank you for your help. I'm new here and don't have any idea.
0
whitetea
Asked:
whitetea
  • 2
1 Solution
 
Jorge PaulinoIT Pro/DeveloperCommented:
Can you show some code/example? What versions of VB are you using ?
0
 
whiteteaAuthor Commented:
Dim i as interger
Dim j as interger

string1 as string
string2 as string
string3 as string

            For i = 1 To j - 1
                With Results(i)
                    If String.IsNullOrEmpty(.String1.ToString) = False And _
                    String.IsNullOrEmpty(.String2.ToString) = False And _
                    String.IsNullOrEmpty(.String3.ToString) = False Then
                        Response.Write(.String1)
                        Response.Write(.String2)
                        Response.Write(.String3)
                    ElseIf String.IsNullOrEmpty(.String1.ToString) = False And _
                        String.IsNullOrEmpty(.String2.ToString) = False Then
                        Response.Write(.String1)
                        Response.Write(.String2)
                    ElseIf String.IsNullOrEmpty(.String1) = False And _
                        String.IsNullOrEmpty(.String3) = False Then
                        Response.Write(.String1)
                        Response.Write(.String3)
                    ElseIf String.IsNullOrEmpty(.String2) = False And _
                        String.IsNullOrEmpty(.String3) = False Then
                        Response.Write(.String2)
                        Response.Write(.String3)
                    Else
                    End If
                End With

            Next i
 
I get more than one result returned. This is wrong. I only want one string set return with most field fill in (some of them are empty)

I'm using Visual studio 2005.

Thank you.
0
 
whiteteaAuthor Commented:
 This has been solved  as follwing:
                  Dim a As Integer
                    Dim N As Integer
                    Dim M As Integer
                    Dim T As Integer
                    Dim Rs Integer
                    R = 0
                   a=0
                    T=0
                    Dim S1[a] as String
                    Dim S2[a] as String
                    Dim S3[a] as String

                    For a = 0 To N - 1
                              If String.IsNullOrEmpty(S1) = False Then
                                Temp = Temp + 1
                            End If
                            If String.IsNullOrEmpty(S2) = False Then
                                Temp = Temp + 1
                            End If
                            If String.IsNullOrEmpty(S3) = False Then
                                Temp = Temp + 1
                            End If
                             If T>= M Then
                                M = Temp
                                Rs = a
                            End If
                        End With
                    Next a
Response.Write(S1(Rs))
Response.Write(S2(Rs))
Response.Write(S3(Rs))

0
 
mlmccCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now