![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Dec 2005
Posts: 4
Rep Power: 0
![]() |
Help with prog
Hi all, I'm doing this Visual Basic prog for my coursework task, but I'm crap at VB. It has to take the size of a directory and the names & transfer speeds of 5 hard disks, and calculate then print each speed. It then has to print the fastest HD out again below using the same headings.
Option Explicit
Option Base 1
------------------------------------------------------------
Private Sub cmdCalc_Click()
Dim loops As Integer
Dim rate(5) As Integer
Dim drive(5) As String
Dim min, max As Integer
Dim dir As Long
Dim fast As Integer
Dim element As Integer
Dim time As Long
dir = InputBox("Please enter the size of the Directory being transferred")
drive(loops) = get_alpha("Name")
For loops = 1 To 5
rate(loops) = get_alpha(100, 10000, "Transfer rate")
time(loops) = 0 'Put time calc here
picDisplay.Print Tab(15); "Name of HD"; Tab(40); "Transfer Rate";
Tab(65); "Directory Size"; Tab(90); "Transfer time"
picDisplay.Print Tab(15); drive(loops); Tab(40); rate(loops);
Tab(65); dir(loops); Tab(90); time(loops)
Next
element = get_max(fast())
picDisplay.Print "The fastest hard disk is " & element
End Sub
------------------------------------------------------------------------------
Public Function get_alpha(ByVal low, ByVal high) As Integer
get_alpha = InputBox("enter the " & note)
While get_alpha < low Or get_alpha > high
get_alpha = InputBox("out of range, re-enter")
Wend
End Function
-----------------------------------------------------------------------------
Public Function get_max(fast) As Integer
Dim fastest As Integer
Dim loops As Integer
fastest = fast(1)
get_max = 1
For loops = 2 To 5
If fast(loops) > fastest Then
fastest = fast(loops)
get_max = loops
End If
Next
End Function
-------------------------------------------------------------------------
Private Sub cmdEnd_Click()
Dim leave As Integer
leave = MsgBox("Are you sure you want to exit?", 36, "Exit?")
If leave = 6 Then
End
End If
End SubAny help would be appreciated |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Doesn't matter if you're crap at VB: IMO, VB is crap itself
. What does matter is that you didn't tell us what your problem is. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Dec 2005
Posts: 4
Rep Power: 0
![]() |
lol that might be useful,
drive(loops) = get_alpha("Name")
For loops = 1 To 5
rate(loops) = get_alpha(100, 10000, "Transfer rate")Ok, whenever I try to run the prog it gives me "argument not optional" and highilights get_alpha on the drive(loops) it does the same with rate. I'm not sure what wrong there. And how can I validate rate, but not drive with one public function? |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Dec 2005
Posts: 4
Rep Power: 0
![]() |
Ok, I've solved that problem by myself, And I know have it almost fully working. But 2 problems left
1)My directory size (dir) is automactically rounded up (I'm using 4.8 it goes to 5) how can I stop this??? 2)I need help getting the detalis of the fastest hard disk to print out below the details of all of the hard disks. (I'm using public function "get_max" to try and find it) This is the code I'm now using Option Explicit
Option Base 1
--------------------------------------------------------------------
Private Sub cmdCalc_Click()
Dim loops As Integer
Dim rate(5) As Integer
Dim drive(5) As String
Dim min, max As Integer
Dim dir As Single
Dim fast As Integer
Dim element As Integer
Dim time As Long
dir = InputBox("Please enter the size of the Directory being transferred")
For loops = 1 To 5
drive(loops) = InputBox("Please enter then name of the drive")
rate(loops) = get_details(100, 10000, "transfer rate")
time = get_time(dir, rate(loops))
picDisplay.Print Tab(15); "Name of HD"; Tab(40); "Transfer Rate"; Tab(65); "Directory Size"; Tab(80); "Transfer time"
picDisplay.Print Tab(15); drive(loops); Tab(40); rate(loops); Tab(65); dir; Tab(80); time
Next
element = get_max(fast)
picDisplay.Print "The fastest hard disk is " & element
End Sub
---------------------------------------------------------------------
Public Function get_details(ByVal low, ByVal high, ByVal note) As Integer
get_details = InputBox("enter the " & note)
While get_details < low Or get_details > high
get_details = InputBox("out of range, re-enter")
Wend
End Function
-----------------------------------------------------------------------
Public Function get_max(fast) As Integer
Dim fastest As Integer
Dim loops As Integer
fastest = fast(1)
get_max = 1
For loops = 2 To 5
If fast(loops) > fastest Then
fastest = fast(loops)
get_max = loops
End If
Next
End Function
------------------------------------------------------------------------------
Private Sub cmdEnd_Click()
Dim leave As Integer
leave = MsgBox("Are you sure you want to exit?", 36, "Exit?")
If leave = 6 Then
End
End If
End Sub
----------------------------------------------------------------------------
Public Function get_time(ByVal dir, ByVal rate)
get_time = dir * 8 * 1024 / rate
End FunctionAnd help would really be appreciated ![]() |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Dec 2005
Posts: 4
Rep Power: 0
![]() |
Woo finally sorted it myself, just goes to show what typing random things into VB does
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|