[VB6] Remove Spaces from the end of your AB items

Discussion in 'Code Snippets and Tutorials' started by the_skip, Jun 28, 2007.

  1. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    Code (Visual Basic):
    1. <div class="vb" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Public</span> <span style="color: #b1b100;">Function</span> remove_spaces<span style="color: #66cc66;">(</span>list <span style="color: #b1b100;">As</span> ListBox<span style="color: #66cc66;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Dim</span> z <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Dim</span> bolexit <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Boolean</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">bolexit =  <span style="color: #b1b100;">false</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">z = <span style="color: #cc66cc;">0</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">bolexit = <span style="color: #b1b100;">False</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Do</span> Until z > list.<span style="color: #66cc66;">ListCount</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">    <span style="color: #b1b100;">Do</span> Until bolexit = <span style="color: #b1b100;">True</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #b1b100;">If</span> <span style="color: #b1b100;">Right</span><span style="color: #66cc66;">(</span>list.<span style="color: #66cc66;">list</span><span style="color: #66cc66;">(</span>z<span style="color: #66cc66;">)</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">)</span> = <span style="color: #ff0000;">" "</span> <span style="color: #b1b100;">Then</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            list.<span style="color: #66cc66;">list</span><span style="color: #66cc66;">(</span>z<span style="color: #66cc66;">)</span> = <span style="color: #b1b100;">Left</span><span style="color: #66cc66;">(</span>list.<span style="color: #66cc66;">list</span><span style="color: #66cc66;">(</span>z<span style="color: #66cc66;">)</span>, <span style="color: #b1b100;">Len</span><span style="color: #66cc66;">(</span>list.<span style="color: #66cc66;">list</span><span style="color: #66cc66;">(</span>z<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #b1b100;">Else</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            bolexit = <span style="color: #b1b100;">True</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #b1b100;">Loop</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">    z = z + <span style="color: #cc66cc;">1</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Loop</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Function</span></li></ol></div>
    This code will remove the spaces at the end of the listbox you can change it to get it from the begging also
     
  2. omgcat

    omgcat Level IV

    Joined:
    Jan 31, 2007
    Messages:
    1,137
    Likes Received:
    0
    Re: Remove Spaces from the end of your ab items [vb6]

    You can do this, or you can also open up the txt and Replace all " " with ""

    :D
     
  3. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    Re: Remove Spaces from the end of your ab items [vb6]

    nope, that will turn Bony Grarrl Club into BonyGrarrlClub and this does it in the listbox, not the file.
     
  4. X Joe Kickass X

    X Joe Kickass X Level IV

    Joined:
    Nov 18, 2006
    Messages:
    1,401
    Likes Received:
    0
    Location:
    Behind You
    Is there a code you can make that would add a capitial to the the first letter and to the first letter thats right beside a space? So say if it was rainbow plushie you could make it into Rainbow Plushie
     
  5. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    yes there is would you want it to be coded into a .exe file.
     
  6. omgcat

    omgcat Level IV

    Joined:
    Jan 31, 2007
    Messages:
    1,137
    Likes Received:
    0
    Could you? and send it to me or post it here? :D Ill +Rep :)
     
  7. sLAUGHTER

    sLAUGHTER Newbie

    Joined:
    Apr 2, 2008
    Messages:
    4
    Likes Received:
    8
    Location:
    Jersey
    sorry, but this is bothering me, would this be considered gravedigging if its helpful?

    o.o

    visual basic has a function to erase leading spaces for you.

    the Trim(string) function :p

    Code (Text):
    1. <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; Public Function remove_spaces(list As ListBox)</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; Dim z As integer</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; For z=0 to list.listcount-1</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; list.list(z) = trim(list.list(z))</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; Next z</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; End Function</li></ol></div>
    Along with putting in the trim function, i made it much simpler and quicker. sorry for bursting your bubble, or gravedigging
     
    Zach likes this.
  8. Laser Wave

    Laser Wave Newbie

    Joined:
    Apr 16, 2007
    Messages:
    5
    Likes Received:
    1
    It also has lTrim() and rTrim() so you can trim from the left or right. :p
     
  9. Zach

    Zach Newbie

    Joined:
    May 26, 2008
    Messages:
    31
    Likes Received:
    1
    Re:

    Yes it is done using the StrConv function.

    Example:

    Code (Text):
    1. Public Sub ProperCase (ByVal List1 As ListBox)
    2. Dim x As Integer
    3.      For x = 0 to List1.ListCount - 1
    4.      List1.List(x) = strConv(List1.List(x), vbProperCase)
    5.      Next x
    6. End Sub
    (Sorry for possible "gravedig", but I want to contribute)

    -Zach