none
String In List T RRS feed

  • Question

  • Hi All,

    I have a simple question.

    the Result after put a Maxima value (ListFoundMax) join with number 0 to 9.

    780

    781

    782

    783

    ....

    789

    170

    171

    172

    173

    .....

    179

    Option Strict On
    Option Explicit On
    Option Infer Off
    
    Imports System.IO
    Imports System.Data
    Imports System.Text
    
    Public Class Form1
        Private C_ As New List(Of String)
        Private F_ As New List(Of String)
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            F_.Add("99")
            F_.Add("99")
            F_.Add("78")
            F_.Add("55")
            F_.Add("92")
            F_.Add("92")
            F_.Add("76")
            F_.Add("17")
            F_.Add("53")
            F_.Add("31")
    
            C_.Add("101")
            C_.Add("203")
            C_.Add("665")
            C_.Add("205")
            C_.Add("321")
            C_.Add("442")
            C_.Add("505")
            C_.Add("665")
            C_.Add("663")
            C_.Add("321")
    
            For i As Integer = 0 To C_.Count - 1
                ListBox1.Items.Add(C_(i) & "   " & F_(i))
            Next
    
            For i As Integer = 0 To C_.Count - 1
                TextBox1.AppendText(C_(i) & "   " & F_(i) & vbCrLf)
            Next
    
        End Sub
    
        Private ListFound As New List(Of Integer)
        Private ListCount As New List(Of Integer)
        Private ListFoundMax As New List(Of Integer)
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            Dim ind As Integer = 0
            For Each s As String In F_
                If Integer.TryParse(s, New Integer) Then
                    If s.Length = 2 Then
                        If Not (s(0) = s(1)) Then
                            TextBox2.AppendText(s & "  " & C_(ind) & vbCrLf)
                            ListFound.Add(CInt(s))
                            ListCount.Add(CInt(C_(ind)))
                        End If
                    End If
                End If
                ind += 1
            Next
    
            For I As Integer = 0 To ListCount.Count - 1
                If ListCount(I) = ListCount.Max Then TextBox3.AppendText(ListCount.Max & "    " & ListFound(I) & vbCrLf)
                ListFoundMax.Add(ListFound(I))
            Next
    
    
    
    
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
            For I As Integer = 0 To ListFoundMax.Count - 1
                TextBox4.AppendText(ListFoundMax(I) & vbCrLf)
            Next
    
        End Sub
    
    End Class
    

    Thank.

    Thursday, April 6, 2017 5:36 AM

Answers

  • In texbox3 show the maxima value and then put to the List "ListFoundMax".

    665 78
    665 17

    from that try to join 78 and 17 with the number from 0 to 9.The result should be show like bellow;

    You should have included that information in your initial post.  I have assumed you want the list displayed in a textbox - if you want it displayed some other way you need to make that change for yourself.

    To display those values in an additional list you need to have them available in a list of their own. Then iterate over that list and append the digits 0 to 9 in a loop.

        Private ListFound As New List(Of Integer)
        Private ListCount As New List(Of Integer)
        Private ListFoundMax As New List(Of Integer)
        Private ListFoundOther As New List(Of Integer)
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ind As Integer = 0
            For Each s As String In F_
                If Integer.TryParse(s, New Integer) Then
                    If s.Length = 2 Then
                        If Not (s(0) = s(1)) Then
                            TextBox2.AppendText(s & "  " & C_(ind) & vbCrLf)
                            ListFound.Add(CInt(s))
                            ListCount.Add(CInt(C_(ind)))
                        End If
                    End If
                End If
                ind += 1
            Next
    
            For I As Integer = 0 To ListCount.Count - 1
                If ListCount(I) = ListCount.Max Then
                    TextBox3.AppendText(ListCount.Max & "    " & ListFound(I) & vbCrLf)
                    ListFoundOther.Add(ListFound(I))
                End If
                ListFoundMax.Add(ListFound(I))
            Next
    
            For Each i As Integer In ListFoundOther
                For j As Integer = 0 To 9
                    TextBox5.Text &= i.ToString & j.ToString & vbCrLf
                Next
            Next
    
        End Sub

    • Marked as answer by mipakteh Thursday, April 6, 2017 8:35 AM
    Thursday, April 6, 2017 7:27 AM

All replies

  • I have a simple question.

    You haven't asked a question.  You should explain what that code is supposed to do.  What result did you expect to get, and what result did you actually get?  Why did you expect to get that particular result?

    Thursday, April 6, 2017 5:53 AM
  • Kindly let us know what is the problem you are facing.

    --------------------------------------------------------

    Surender Singh Bhadauria

    My Blog

     

    Thursday, April 6, 2017 5:55 AM
  • ok,

    In texbox3 show the maxima value and then put to the List "ListFoundMax".

    665 78

    665 17

    from that try to join 78 and 17 with the number from 0 to 9.The result should be show like bellow;

    780

    781

    ....

    789

    and 

    170

    171

    ....

    179

    thank


    • Edited by mipakteh Thursday, April 6, 2017 7:03 AM add
    Thursday, April 6, 2017 7:00 AM
  • In texbox3 show the maxima value and then put to the List "ListFoundMax".

    665 78
    665 17

    from that try to join 78 and 17 with the number from 0 to 9.The result should be show like bellow;

    You should have included that information in your initial post.  I have assumed you want the list displayed in a textbox - if you want it displayed some other way you need to make that change for yourself.

    To display those values in an additional list you need to have them available in a list of their own. Then iterate over that list and append the digits 0 to 9 in a loop.

        Private ListFound As New List(Of Integer)
        Private ListCount As New List(Of Integer)
        Private ListFoundMax As New List(Of Integer)
        Private ListFoundOther As New List(Of Integer)
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ind As Integer = 0
            For Each s As String In F_
                If Integer.TryParse(s, New Integer) Then
                    If s.Length = 2 Then
                        If Not (s(0) = s(1)) Then
                            TextBox2.AppendText(s & "  " & C_(ind) & vbCrLf)
                            ListFound.Add(CInt(s))
                            ListCount.Add(CInt(C_(ind)))
                        End If
                    End If
                End If
                ind += 1
            Next
    
            For I As Integer = 0 To ListCount.Count - 1
                If ListCount(I) = ListCount.Max Then
                    TextBox3.AppendText(ListCount.Max & "    " & ListFound(I) & vbCrLf)
                    ListFoundOther.Add(ListFound(I))
                End If
                ListFoundMax.Add(ListFound(I))
            Next
    
            For Each i As Integer In ListFoundOther
                For j As Integer = 0 To 9
                    TextBox5.Text &= i.ToString & j.ToString & vbCrLf
                Next
            Next
    
        End Sub

    • Marked as answer by mipakteh Thursday, April 6, 2017 8:35 AM
    Thursday, April 6, 2017 7:27 AM
  • Thank you very much Acamar;

    Thursday, April 6, 2017 8:35 AM