473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Calculating amounts using VB

9
Hi!

I was wondering if I could get some more excellent advice from this site. I'm designing a project that ultimately, among other functions, calculates a download time based upon a file size (which is loaded at run time by the user), a specified percentile of compression (selected by the user - 0-10%) and a download rate numerical up down box (also user specified - 1-10kb/s).
I figured that this just might be a glorified version of a VAT calculator, and I think I've figured out the code, I just dont know how to get it to execute from within the program. I have two text boxes and a button. The boxes show the KB/s rate and the amount of seconds it's going to take to download the file at the specified KB/s rate.

Here is the code

Expand|Select|Wrap|Line Numbers
  1.         'Dim dblCompressionRate, dblCompression, dblCompressedFileSize, dblTotalSeconds, dblRate, dblSizeText
  2.         filesize = FileLen(file)
  3.  
  4.         'Calculate total compressed file size, based upon user settings
  5.         dblCompressionRate = numCompression.Value
  6.         dblSizeText = lblSize.Text
  7.         dblCompression = dblCompressionRate.value / dblSizeText * 10
  8.         dblCompressedFileSize = dblSizeText - dblCompression
  9.  
  10.  
  11.         'Calculate total download time, using compression rate and download speed - and display it in a box
  12.         numKB = dblRate
  13.         dblTotalSeconds = dblCompressedFileSize / dblRate
  14.         txtSec.Text = dblTotalSeconds
  15.  
  16.         Display total download rate in second box
  17.         txtKB.Text = numKB.Value
I've tried putting it on the button event, but it doesn't seem to be working, I'm sure somewhere I'm not actually telling VB what to do with my (hopefully correct) code!

Can anyone help?

TIA!

Sam
Nov 6 '07 #1
2 1567
Killer42
8,435 Expert 8TB
I don't think you said what version of VB you're using.

Anyway, I'd say probably your best bet is to place this code in a Private Sub (in the form) and call it from the change events whenever the user changes something. Or possibly from a timer.
Nov 6 '07 #2
dablyz
9
I don't think you said what version of VB you're using.

Anyway, I'd say probably your best bet is to place this code in a Private Sub (in the form) and call it from the change events whenever the user changes something. Or possibly from a timer.
Apologies - im using VB.NET express edition

I did manage to solve it in the end - and here is the code, if anyone needs it - you were right, it did involve a counter!

Expand|Select|Wrap|Line Numbers
  1.     Private Sub btnCalculate_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
  2.  
  3.         Dim FileSize As Double
  4.         If (radJPG.Checked) Then
  5.             If (numCompression.Value = 0) Then
  6.                 'FileSize = (FileLen(txtSize.Text)) / 1024
  7.                 FileSize = (txtSize.Text) / 1024
  8.             Else
  9.                 'FileSize = ((FileLen(txtSize.Text)) / 1024) * (1 - (numCompression.Value / 100))
  10.                 FileSize = (txtSize.Text) / 1024 * (1 - (numCompression.Value / 100))
  11.             End If
  12.         Else
  13.             FileSize = (txtSize.Text) / 1024
  14.         End If
  15.         counter = (FileSize / numKB.Value)
  16.         txtSec.Text = Str(counter) + "secs"
  17.  
  18.     End Sub
  19.  
Thanks!
Nov 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
4
by: The Bit Bandit | last post by:
Hopefully someone can help me create a query that I'm having some trouble with. I have three tables: invoices, invoicedetails, invoicepayments The fields are: invoices -------- InvoiceNo
4
by: oshanahan | last post by:
Does anyone have ideas on the best way to move large amounts of data between tables? I am doing several simple insert/select statements from a staging table to several holding tables, but because...
2
by: MT | last post by:
Hi, I have an invoicing system using postgresql. Each time a customer makes a purchase, a new record is inserted into the "cart" table. The "cart" table, among other things, contains a customer_id...
5
by: Julia Baresch | last post by:
Hi everyone, I haven't found any reference to this problem on this group or in Access 97 help. I hope someone here knows this - probably a simple thing, but not obvious. I designed a query to...
2
by: Dennis C. Drumm | last post by:
What is the best way to add several pages of text to a readonly TextBox? The text does not change and was created in a Word rtf document but could as easly be put in a ASCII text file. Can this be...
0
by: Marina | last post by:
Access 2002: I have an Accounts form that allows the user to enter billing anounts and payment amounts that will then be added to a transaction table. This table is used for the Accounts...
7
by: =?Utf-8?B?TW9iaWxlTWFu?= | last post by:
Hello everyone: I am looking for everyone's thoughts on moving large amounts (actually, not very large, but large enough that I'm throwing exceptions using the default configurations). We're...
28
by: CindySue | last post by:
I found something similar, but can't get it to work--maybe because I'm working in a report rather than a query? I have a main report that has three subreports in it. Each subreport has a total for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.