[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

File Size Calc 4 CD

Posted on 2001-06-20
5
Medium Priority
?
209 Views
Last Modified: 2010-05-02
Hi PPL:
I have a huge amount of CD's I have to carry around in my car and I want to cut it down as much as possible. What I have done is in a ListView I have listed the program name in col 1 and its size in MB in the second. What I want to now do is have my program calculate which programs can be shorted and will add up as close to 700MB to fill a CD.

So basiclly I have a list of apps and the file size for that app. I need some code which will write in col 3 which CD that app should go onto. IE 1,2,3 so that it will total up to 700MB or around 700MB. Bottom line I want to get as much as I can on each CD...
0
Comment
Question by:hollstar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6212476
why dont you tack on some more points because what you are asking for is custom code and that takes time.
0
 

Author Comment

by:hollstar
ID: 6212486
How many do you want in total?
0
 

Author Comment

by:hollstar
ID: 6212532
I should also mention that I do need to be able to save & load this information to file. A TXT file will do. I have used a sample below:

Icon Edit Pro|1.37|
WinZip|2.97|


Please Note: After the last | this is the location of the CD number once the user has calculated the information.

Also note the save and load function must use a dialog box.
0
 
LVL 6

Accepted Solution

by:
sharmon earned 800 total points
ID: 6212570
I wrote a sample for you to do this with.  Anyhow, to run this sample, just create a form with one listview and one command button.  Leave them at their default names, (Listview1 & Command1).  Copy this code to it and run it...I manually added generic numbers to the listview at runtime to test with....I am sure there are other ways to do it, this is the first thing I thought of.  As far as loading and saving a listview, there are already alot of questions about this asked, you should search the site, no point in rewriting all that again.  I have already answered that a couple times for people.  If you can't find it, I'll post my answer again.


'Copy this code to the form as setup above...

Option Explicit

Private Type TCDMEGS
  dblMBs As Double
End Type

Dim CDMegs() As TCDMEGS

Private Sub Form_Load()
  ListView1.ColumnHeaders.Clear
  ListView1.ColumnHeaders.Add , , "Program"
  ListView1.ColumnHeaders.Add , , "Size"
  ListView1.ColumnHeaders.Add , , "Which CD"
  ListView1.View = lvwReport
 
  Dim xItem As ListItem
 
  Set xItem = ListView1.ListItems.Add(, , "Program A")
  xItem.SubItems(1) = "50"
 
  Set xItem = ListView1.ListItems.Add(, , "Program B")
  xItem.SubItems(1) = "250"
 
  Set xItem = ListView1.ListItems.Add(, , "Program C")
  xItem.SubItems(1) = "450"
 
  Set xItem = ListView1.ListItems.Add(, , "Program D")
  xItem.SubItems(1) = "250"
 
  Set xItem = ListView1.ListItems.Add(, , "Program E")
  xItem.SubItems(1) = "5"
 
  Set xItem = ListView1.ListItems.Add(, , "Program F")
  xItem.SubItems(1) = "85"
 
  Set xItem = ListView1.ListItems.Add(, , "Program G")
  xItem.SubItems(1) = "1.44"
 
  Set xItem = ListView1.ListItems.Add(, , "Program H")
  xItem.SubItems(1) = "100"
 
  Set xItem = ListView1.ListItems.Add(, , "Program I")
  xItem.SubItems(1) = "750"
End Sub

Private Sub Command1_Click()
  Dim i As Integer
  ReDim CDMegs(0)
 
  CDMegs(0).dblMBs = 0
 
  If ListView1.ListItems.Count < 1 Then Exit Sub
 
  For i = 1 To ListView1.ListItems.Count
    ListView1.ListItems(i).SubItems(2) = _
      WhichCD(CDbl(ListView1.ListItems(i).SubItems(1)))
  Next i
End Sub

Private Function WhichCD(ByVal dblMBs As Double) As Integer
  Const intMaxMB As Integer = 700
  Dim i As Integer
  Dim x As Integer
 
  If dblMBs > intMaxMB Then
    WhichCD = 0
    Exit Function
  End If
 
  For i = 0 To UBound(CDMegs)
    If CDMegs(i).dblMBs + dblMBs <= intMaxMB Then
      WhichCD = i + 1
      CDMegs(i).dblMBs = CDMegs(i).dblMBs + dblMBs
      Exit Function
    End If
  Next i
 
  x = UBound(CDMegs) + 1
  ReDim Preserve CDMegs(x)
  CDMegs(x).dblMBs = dblMBs
  WhichCD = x + 1
End Function
0
 

Author Comment

by:hollstar
ID: 6212629
Fine with me sharmon!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question