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 - 'Dim dblCompressionRate, dblCompression, dblCompressedFileSize, dblTotalSeconds, dblRate, dblSizeText
-
filesize = FileLen(file)
-
-
'Calculate total compressed file size, based upon user settings
-
dblCompressionRate = numCompression.Value
-
dblSizeText = lblSize.Text
-
dblCompression = dblCompressionRate.value / dblSizeText * 10
-
dblCompressedFileSize = dblSizeText - dblCompression
-
-
-
'Calculate total download time, using compression rate and download speed - and display it in a box
-
numKB = dblRate
-
dblTotalSeconds = dblCompressedFileSize / dblRate
-
txtSec.Text = dblTotalSeconds
-
-
Display total download rate in second box
-
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
2 1590
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.
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! -
Private Sub btnCalculate_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
-
-
Dim FileSize As Double
-
If (radJPG.Checked) Then
-
If (numCompression.Value = 0) Then
-
'FileSize = (FileLen(txtSize.Text)) / 1024
-
FileSize = (txtSize.Text) / 1024
-
Else
-
'FileSize = ((FileLen(txtSize.Text)) / 1024) * (1 - (numCompression.Value / 100))
-
FileSize = (txtSize.Text) / 1024 * (1 - (numCompression.Value / 100))
-
End If
-
Else
-
FileSize = (txtSize.Text) / 1024
-
End If
-
counter = (FileSize / numKB.Value)
-
txtSec.Text = Str(counter) + "secs"
-
-
End Sub
-
Thanks!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 feedback on how I might do things differently to make it
either more consice, readable, or faster. ie... are there better ways
to do it in Python?
It won't break any records for calculating pi, that wasn't my goal,
learning Python was. But it might...
|
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
|
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 of the
volume it is taking an extraordinary amount of time. I considered
using cursors but have read that may not be the best thing for this
situation. Any thoughts?
--
Posted using the http://www.dbforumz.com interface, at author's request...
|
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 field and a total for the amount purchased on the particular invoice. Now what I'd like to do is to calculate the total invoices for each customer in a given time interval, then list those customers in descending order from most paying to least...
|
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 pull payment data from my database for
accounting. It has 3 tables with one-to-many joins:
Table1 --> one-to-many --> Table2 --> one-to-many --> Table3
The payment amount field is in Table3. I entered a few negative
| |
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 done using a resource or
something? Can TextBoxes be attached to data sources other than database
objects?
Thanks,
Dennis
|
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 Subform.
I have a field for Account Balance on the accounts form that should
take the total amount billed for that client and subract the amount
paid.
|
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 doing a proof-of-concept on WCF whereby we have a Windows form client
and a Server. Our server is a middle-tier that interfaces with our SQL 05
database server.
|
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 items in that subreport. If all three have entries, I can get a grand total, but if one or more doesn't, it just says error. I first tried using IIf/IsNull, but again, I get totals only when all three subreports have amounts. I then found nz, and...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |