Results 1 to 17 of 17

Thread: [RESOLVED] Generate numbers in a Textbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Resolved [RESOLVED] Generate numbers in a Textbox

    Code:
    Private Sub Command1_Click()
    List1.List(List1.ListIndex) = Text1 + 1
    End Sub
    
    Private Sub Timer1_Timer()
    Text1.Text = List1.ListCount
    End Sub
    Hi everyone,

    I've been trying to generate numbers starting from a specific giving number using a Textbox, Listbox, and a Timer.
    But so far I have only been able to generate or add numbers starting from number 1 on the Listbox from the Textbox.
    Thats because of the method I am using maybe? since this code works base on each line being counted from the Listbox.
    The idea was to generate numbers in a Textbox starting from a giving number, like starting from number: 156, etc.
    My project consists of a Textbox, Listbox, Timer, and a button, is there a better way to accomplish this task?
    I must add that the numbers generated must be added to the listbox since I will be joining them with extra data.
    Any help will be very appreciated.
    Last edited by Coding; May 29th, 2015 at 09:21 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Generate numbers in a Textbox

    It is not clear what you are trying to do, you need to give a better more detailed description. All I can tell is that you want to add some numbers to a listbox and display? each? number in a text box using a timer. I have no clue what the numbers are nor how you want to derive them and as such can not offer proper advice beyond telling you to describe better.

  3. #3
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Generate numbers in a Textbox

    Isn't the following is enough
    Code:
    Private Sub Command1_Click()
        List1.List(List1.ListIndex) = List1.List(List1.ListIndex) + 1
    End Sub



  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    I need those number to join them together with three other listboxes.
    Example: Sub Task_Numbers()
    Example: Sub Task_156()
    List1 will add: Sub
    List2 will add: Task_
    List3 will add: Numbers
    List4 will add: ()
    I have done this before, but starting from number 1
    Now I would like to make a second project in which I can start from a desired number.
    Last edited by Coding; May 29th, 2015 at 09:53 PM.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    Thanks 4x2y, but I am getting this error:
    Name:  Example.jpg
Views: 121
Size:  17.0 KB

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Generate numbers in a Textbox

    Quote Originally Posted by Coding View Post
    I need those number to join them together with three other listboxes.
    Example: Sub Task_Numbers()
    Example: Sub Task_156()
    List1 will add: Sub
    List2 will add: Task_
    List3 will add: Numbers
    List4 will add: ()
    I have done this before, but starting from number 1
    Now I would like to make a second project in which I can start from a desired number.
    I still have no clue what you are trying to say

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    Read DataMiser, just read

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    I made this small gif to show what am doing:
    http://makeagif.com/i/QxknKy
    Attached Images Attached Images  

  9. #9
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Generate numbers in a Textbox

    Quote Originally Posted by Coding View Post
    Thanks 4x2y, but I am getting this error:
    Name:  Example.jpg
Views: 121
Size:  17.0 KB
    This is because the list of is empty and there is no item selected

    Why you need all these lists?
    Code:
     
    Private Sub Command1_Click()
        Dim s As String 
        For j = 156 To 256
            s = "Sub "  & "Task_" & j & "()" 
            List1.AddItem s
        Next
    End Sub
    You can use TextBox to enter start and end of loop



  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    I don't know how to put it more simple than what I have already done it.
    But let me explain, I have 1745 lines of code text that I most edit and put it together,
    so every time I ran into this situation instead of coding it manually I always make a projects
    to make it faster and easier, so what I do is copy and paste the whole 1745 lines of text into
    one of the List Boxes and then everything take place in a click of a button after I make sure that
    the right amount of lines or numbers are in place, so what this does is that it grab line by line
    and put everything together adding extra codes, like: Sub, ( ), and so on, like the next example:
    Sub Task_81()
    'each line of code is added here
    End Sub

    Sub Task_82()
    'each line of code is added here
    End Sub

    Sub Task_83()
    'each line of code is added here
    End Sub

    And so on, but I'll take care all of that myself, what I really need is to get those numbers
    generate on the Listbox, but like I said, I really want to set a number frame, like if I want
    to start from number: 234, etc.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    START A PROJECT, ADD A LISTBOX, TEXTBOX, TIMER, BUTTON.
    PASTE THE FOLLOWING CODE ON THE PROJECT AND TAKE A LOOK.
    Code:
    Private Sub Command1_Click()
    List1.List(List1.ListIndex) = Text1 + 1
    End Sub
    
    Private Sub Timer1_Timer()
    Text1.Text = List1.ListCount
    End Sub
    WITH THIS CODE YOU CAN GENERATE NUMBERS STARTING FROM 1,
    BUT MY GOAL IS TO GENERATE NUMBERS FROM A GIVING NUMBER.
    SO IF I WOULD LIKE TO START FROM 50, LEST TYPE 50 IN TEXTBOX.
    THEN THE NUMBER WILL START GENERATING FROM 50 AND SO ON.
    BUT FOR ALL OF YOU WHO HAVE A LOT OF EXPERIENCE WITH VB6,
    I THINK THAT THERE IS NO NEED TO MAKE THIS PROJECT, AS IT IS
    VERY SIMPLE TO JUST MAKE IT ON YOUR HEAD AND SIMULATE IT.
    BUT AGAIN I WILL APPRECIATE SOME HELP.

  12. #12
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Generate numbers in a Textbox

    Quote Originally Posted by Coding View Post
    Read DataMiser, just read
    I did read and what I read amounts to little more than gibberish. You talk about numbers but never say what numbers, where they come from or how they come about then talk about joining them together with other listboxes with no mention of how they are to be joined, nor what conditions apply nor what is in the listboxes. In short you have basically included just nothing that could help solve whatever issue it is you are having.

    You say you have done this before but starting at one yet you do not give us any clue as to what "this" is

    Anyway if the best you can do is tell me to read that gibberish then I can't help you.

    You really need to learn how to put into words what you are trying to do.

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Generate numbers in a Textbox

    btw this code
    Code:
    Private Sub Command1_Click()
    List1.List(List1.ListIndex) = Text1 + 1
    End Sub
    
    Private Sub Timer1_Timer()
    Text1.Text = List1.ListCount
    End Sub
    Would either crash or just repeatedly update 1 entry in a listbox. Nothing is added to any list there the timer does nothing but display the list count which from your gif would be 0 because there is nothing in the list. If you want to add items to a list then you need to use the additem method but again I have no clue what you are really trying to do because you failed to describe it properly even after being asked and I have wasted enough time on this so good luck.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    Hey come on man, don't say that, i have that code here right now,
    and what it does is that on each click on the button a number is
    generate, and goes from 1 and up.

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    Bad try DataMixer, do not try to ruin my project
    Take a closer look at this gif I made just now...
    The problem with me is that I talk to much and I explain less, or I don't know how to explain things.
    And I do not need all the things that I mentioned early, I just need numbers to be generate in a Listbox.
    But not like my example, I want them to start from whatever number I tell them to start with.
    Last edited by Coding; May 30th, 2015 at 01:09 AM.

  16. #16
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Generate numbers in a Textbox

    Don't use timer, just the following only
    Code:
    Private Sub Command1_Click() List1.AddItem Val(Text1.Text) + List1.ListCount
     End Sub



  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2013
    Posts
    330

    Re: Generate numbers in a Textbox

    Thank You! so much 4x2y, this is great, it worked !
    Thank you and thank you too DataMiser

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width