Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 5th, 2005, 3:46 PM   #1
haddow64
Newbie
 
Join Date: Dec 2005
Posts: 4
Rep Power: 0 haddow64 is on a distinguished road
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 Sub


Any help would be appreciated
haddow64 is offline   Reply With Quote
Old Dec 5th, 2005, 3:57 PM   #2
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
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.
Polyphemus_ is offline   Reply With Quote
Old Dec 6th, 2005, 1:17 AM   #3
haddow64
Newbie
 
Join Date: Dec 2005
Posts: 4
Rep Power: 0 haddow64 is on a distinguished road
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?
haddow64 is offline   Reply With Quote
Old Dec 6th, 2005, 10:44 AM   #4
haddow64
Newbie
 
Join Date: Dec 2005
Posts: 4
Rep Power: 0 haddow64 is on a distinguished road
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 Function

And help would really be appreciated
haddow64 is offline   Reply With Quote
Old Dec 7th, 2005, 1:48 PM   #5
haddow64
Newbie
 
Join Date: Dec 2005
Posts: 4
Rep Power: 0 haddow64 is on a distinguished road
Woo finally sorted it myself, just goes to show what typing random things into VB does
haddow64 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC