Small Counter issue


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Small Counter issue

  1. #1
    Join Date
    Sep 2005
    Location
    Netherlands
    Posts
    14

    Small Counter issue

    Has been sometime I have been programming and never was REALLY good but it's fun. I have a small problem. I want to add 10 line's to a Combo box with a number:
    Private Sub Form_Load()
    tmpCount = 1
    Do While tmpCount < 10
    Combo1.AddItem ("Added item" + Str(tmpCount))
    tmpCount = tmpCount + 1
    Loop
    End Sub

    This works fine but I want the number to be attached to the text "Added item" so it reads "Added Item1",etc. Now there is a space between the text and the number looking like "Added Item 1". Anyone know how to fix this?

  2. #2
    Join Date
    Aug 2005
    Posts
    85
    Code:
    Private Sub Form_Load()
        Dim tmpcount
        tmpcount = 1
        Do While tmpcount < 10
            Combo1.AddItem ("Added item" & tmpcount)
            tmpcount = tmpcount + 1
        Loop
    End Sub
    Steve.

  3. #3
    Join Date
    Sep 2005
    Location
    Netherlands
    Posts
    14
    Quote Originally Posted by Steve Grant
    Code:
    Private Sub Form_Load()
        Dim tmpcount
        tmpcount = 1
        Do While tmpcount < 10
            Combo1.AddItem ("Added item" & tmpcount)
            tmpcount = tmpcount + 1
        Loop
    End Sub
    Steve.
    THX

  4. #4
    Join Date
    Sep 2005
    Location
    South Africa
    Posts
    6

    simple

    add trim before

    ie

    Private Sub Form_Load()
    Dim tmpcount
    tmpcount = 1
    Do While tmpcount < 10
    Combo1.AddItem ("Added item" & trim(str$(tmpcount)))
    tmpcount = tmpcount + 1
    Loop
    End Sub
    'this way it avoids the VB6 auto conversion
    'trim cancels the leading space of the number converted


  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Use CStr or Format instead of Str (that adds a space in front of the returned string)

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. Producer Consumer Thread
    By Chirag in forum Java
    Replies: 6
    Last Post: 04-10-2002, 05:22 AM
  2. They created J#, why couldn't they do VB#?
    By Thomas Eyde in forum .NET
    Replies: 290
    Last Post: 12-22-2001, 02:13 PM
  3. Replies: 0
    Last Post: 09-19-2001, 06:48 AM
  4. Small Intra/Inter Net Home Network-DNS Issue
    By Micah Nasarow in forum Enterprise
    Replies: 0
    Last Post: 07-19-2001, 06:13 PM
  5. Creating a hit Counter for offsite web page
    By justin law in forum ASP.NET
    Replies: 0
    Last Post: 01-25-2001, 01:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center