Counting digits from multiple textbox in VB6 VB10 RRS feed

  • Question

  • I need to count or add the number of same digits in a textbox.result from textbox1, textbox2, textbox3, and textbox4. In other words if the user enters "9" in textbox1, "9" in textbox2, "4" in textbox3, and "9" in textbox4, I need to obtain the value of "3" in textbox.result because 9 repeats 3 times. Can someone help me?
    Friday, January 4, 2019 6:08 AM

All replies

  • Check this example in C#:

    string t1 = "9";

    string t2 = "9";

    string t3 = "4";

    string t4 = "9";


    string result =

        new[] { t1, t2, t3, t4 }

            .GroupBy( t => t )

            .OrderByDescending( g => g.Count() )



    Adjust it to deal with textboxes.

    • Edited by Viorel_MVP Friday, January 4, 2019 6:36 AM
    Friday, January 4, 2019 6:35 AM
  • I'm not good at c++ but visual basics 6 or 10
    Friday, January 4, 2019 6:54 AM
  • In modern VB:

    Dim t1 = "9"
    Dim t2 = "9"
    Dim t3 = "4"
    Dim t4 = "9"
    Dim result As String = {t1, t2, t3, t4}.GroupBy(Function(t) t).OrderByDescending(Function(g) g.Count).First.Count.ToString

    Friday, January 4, 2019 7:04 AM
  • Hi friend,

    Welcome to the MSDN forum.

    Refer to the description, your issue is about the Windows Forms development and our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum for a better support, thank you for your understanding.

    Best regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, January 7, 2019 1:44 AM
  • Can't make this work, must be incompatible with vb6.
    Monday, January 7, 2019 11:21 AM
  • Can't make this work, must be incompatible with vb6.

    For VB6, use the following forum.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, January 7, 2019 11:49 AM