Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / March 2004



Tip: Looking for answers? Try searching our database.

Get File Size

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max - 07 Mar 2004 02:02 GMT
I am trying to retrive the total size of files present in a treeview string.
The string is strArray(1) im using ";" as a string seperater and "|" as a
seperater of items within strArray(1). I want to display the total size of
the files in a label. How woould I go about this?
Randy Birch - 07 Mar 2004 05:03 GMT
parse the string, perhaps using Split, convert each value to a number using
Val or CLng, and sum.

Signature

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.

: I am trying to retrive the total size of files present in a treeview string.
: The string is strArray(1) im using ";" as a string seperater and "|" as a
: seperater of items within strArray(1). I want to display the total size of
: the files in a label. How woould I go about this?
Max - 07 Mar 2004 08:09 GMT
Randy - I was going to try something like this but I know its wrong since U
said I must include sum and Im not quite sure how to use the Val function.
Any suggestions for me.
----------------------------begin------------------------
   Dim strArray(1) As String ' I was going to dim the strArray(1) but I am
diming another strArray already in the same Subroutine

       If ndeNode <> ndeNode.Tag Then 'If we do have an item(s) then show
the node's item(s) size.
           strArray(1) = Split(ndeNode.Tag, ";" , "|")(1)
               Text1.Text = ValstrArray(1)
--------------------------end--------------------------

Yea I know its ugly.
Randy Birch - 07 Mar 2004 11:50 GMT
assuming each member of the array was to be summed ...

dim totalsize as long

thearray = split(thestring, whatever, whatever)
  for x = lbound(thearray) to ubound(thearray)
      totalsize = totalsize + val(thearray(x))
  next

if the size was every second item, skip one ..

thearray = split(thestring, whatever, whatever)
  for x = lbound(thearray) to ubound(thearray) step 2
      totalsize = totalsize + val(thearray(x))
  next

I really think storing the data in the tag value of anything is poor
programming practice. A better solution would be defining a local
user-defined type and using that for the data. Then save the index of the
respective user defined type as the tag.

private type myfiledata
 filename as string
 filesize as long
end type

(re)dim mfd (0 to numberoffiles) as myfiledata

  mfd(0).filename = "whatever"
  mfd(0).filesize = 12345

  nod.Tag = 0

... then later ...

 thearrayindex = val(nod.tag)
 thefile = mfd(thearrayindex).filename
 thesize = mfd(thearrayindex).filesize

... or in a loop ...

  for x = lbound(mfd) to ubound(mfd)
      totalsize = totalsize + mfd(0).filesize
  next

Signature

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.

: Randy - I was going to try something like this but I know its wrong since U
: said I must include sum and Im not quite sure how to use the Val function.
[quoted text clipped - 10 lines]
:
: Yea I know its ugly.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.