Results 1 to 11 of 11

Thread: Add up filesize - is it easy? *** RESOLVED - Thx vbNeo ***

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    South West UK
    Posts
    245

    Add up filesize - is it easy? *** RESOLVED - Thx vbNeo ***

    I have the following in a rtb, how can i go through the rtb line by line and add up the SIZE: values ???????

    PATH: C:\Temp\ss_nb.dat | NAME: ss_nb.dat | SIZE: 122 | DATE: 09/09/2003 13:50:29
    PATH: C:\Temp\ss_udp.dat | NAME: ss_udp.dat | SIZE: 240 | DATE: 09/09/2003 13:50:33
    PATH: C:\Temp\ss_udp2.dat | NAME: ss_udp2.dat | SIZE: 4 | DATE: 09/09/2003 13:50:33
    PATH: C:\Temp\Strategy.ppt | NAME: Strategy.ppt | SIZE: 7921152 | DATE: 28/05/2003 11:32:32
    Last edited by HELPmyVB; Dec 10th, 2003 at 11:27 AM.
    A lowly programmer.

    http://www.sentinalgroup.com

  2. #2
    Addicted Member
    Join Date
    Nov 2003
    Location
    India
    Posts
    227
    Can you tell me what is RTB?

    If these informations are stored in a file then read it just line by line and split it using Split() function, you will get the segrigated values.

    Good Luck.

    Jai.
    See you,
    -Jai
    [Friends Never Say Good Bye]

  3. #3
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    Easy as Pie. Hmm... I like pie

    Look in your api text viewer for GetFileSize, look on http://msdn.microsoft.com for additional details. Post back if you need help.

  4. #4
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    he means Rich text box

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    South West UK
    Posts
    245
    I am in a real hurry to get this done, normally like to sort it out myself but need help to get it done quickly. Any chance ?
    A lowly programmer.

    http://www.sentinalgroup.com

  6. #6
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Seeming as you are from North West and not North East of UK i cant help you lol

    Sorry, im no good with this stuff

  7. #7
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    well

    Do you just want to change the string, or the files sizes itself ?
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  8. #8
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    And let me guess, your too lazy to do a web search?

    http://search.yahoo.com/search?p=vb+...t&cop=mss&tab=

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    South West UK
    Posts
    245
    vbNeo, what i need is a sub which adds up the filesizes as posted above and displays the answer in a messagebox e.g.

    Total Filesize = 7,921,518
    A lowly programmer.

    http://www.sentinalgroup.com

  10. #10
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    ohh

    That's easy

    Gimme a sec, I'll make something for you
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  11. #11
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    well

    Try this:

    VB Code:
    1. Public Function AddUp(rtb As RichTextBox)
    2. On Error Resume Next
    3. Dim iStart As Integer
    4. Dim iEnd As Integer
    5. Dim iC As Integer
    6. Dim iNumbers(1000) As Long
    7. Dim Result As Long
    8. iStart = 1
    9. iC = 0
    10. With rtb
    11. Do Until iStart = 0
    12. If InStr(iStart, .Text, "SIZE:") <= 0 Then
    13. iStart = 0
    14. Else
    15. iStart = InStr(iStart, .Text, "SIZE:") + Len("SIZE:") + 1
    16. iEnd = InStr(iStart, .Text, " ")
    17. iNumbers(iC) = Val(Mid(.Text, iStart, iEnd - iStart))
    18. iStart = iStart + 15
    19. iC = iC + 1
    20.  
    21. End If
    22.  
    23. Loop
    24. For I = 0 To iC
    25. Result = Result + iNumbers(I)
    26. Next
    27.  
    28. AddUp = Result
    29.  
    30. End With
    31.  
    32.  
    33. End Function

    call it with

    VB Code:
    1. MsgBox AddUp(RichTextBox1)

    Hope it helps/works

    Cheers!
    Last edited by vbNeo; Dec 10th, 2003 at 11:46 AM.
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

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