Click here to Skip to main content
15,891,887 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Basically this want I want to do:

When I enter 5 in a textbox

Then I press a command button the out put should be:

1
12
123
1234
12345


Please show me the code (vb6)
Posted

1 solution

i can suggest you c# code for your problem statement :


C#
public string ConvertToText(string text)
        {
            int a;
            string output=string.Empty;
            if(Int32.TryParse(text,out a))
            {
                for(int i=1;i<=a;i++)
                {
                    for(int j=1;j<=i;j++)
                    {
                        output +=Convert.ToString(j);
                    }
                    output+="\n"; // here you can replace with specific new line character of vb6
                }
            }
            return output;
        }



and suitable vb code

VB
Public Function ConvertToText(ByVal text As String) As String
       Dim a As Integer
       Dim output As String = string.Empty
       If Int32.TryParse(text, a) Then
           Dim i As Integer = 1
           Do While (i <= a)
               Dim j As Integer = 1
               Do While (j <= i)
                   output = (output + Convert.ToString(j))
                   j = (j + 1)
               Loop
               output = (output + ""& vbLf)
               ' here you can replace with specific new line character of vb6
               i = (i + 1)
           Loop
       End If
       Return output
   End Function
 
Share this answer
 
v3
Comments
Member 10711763 31-Mar-14 6:52am    
Can you please do it in vb6 code
Member 10711763 31-Mar-14 6:53am    
I can't do
Dim a as integer = 0

Vb6 does not allow it
Member 10711763 31-Mar-14 7:28am    
Sorry I meant Visual Basic 2006
F. Xaver 1-Apr-14 5:21am    
there is no Visual Basic 2006 .. there was a 2005 and 2008 Version both .NET

are you sure, you don't mean Visual Basic 6.0 aka VB6 aka Visual Basic Classic
ashok rathod 1-Apr-14 3:11am    
i had updated solution with removing =0 condition. if it helps you and not able to get error and second thing i would suggest to use c# to visual basic 2006 conversion tool available on internet...as i am not familiar with visual basic 2006

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900