Help - Search - Members - Calendar
Full Version: Need Help With Vb
BleepingComputer.com > Software > Programming
   
Cunny
hi i am need of help i am creating a program that will let u enter 5 hard drive name and transfer rate and directory size and it will caculation the fastest time but it is only doing 3 out of the 5 calculations right and the showing me 0 can someone please tell me where i am going wrong
Dim Index As Integer
Dim Hard_drive(4) As String
Dim Transfer_rate(4) As Single
Dim Directory_size As Single
Dim Transfer_time(4) As Single
Dim Transfer_min As Single
Dim Hard_Min As String
Dim Minimum As Single


Private Sub cmdEnd_Click()
End
End Sub

Private Sub cmdEnter_Click()
Call Names(4)
Call Calculation(4)
Call Display(0)
Call Display(1)
Call Display(2)
Call Display(3)
Call Display(4)
Call Min
Call Fastest_display


End Sub

Private Sub Calculation(Index As Integer)
For Index = 0 To 4
Transfer_time(Index) = (Directory_size * 1024 * 8) / Transfer_rate(Index)
Index = Index + 1
Next

End Sub

Private Sub Names(Index As Integer)

For Index = 0 To 4
Hard_drive(Index) = InputBox("Please enter the hard drive name", "Hard Drive")
Transfer_rate(Index) = InputBox("Please enter the Transfer_rate", "Transfer Rate")
Next
Directory_size = InputBox("Please enter the directory size in GigaBytes", "Directory Size")
End Sub

Private Sub Display(ByVal Index As Integer)
whichdrive = InputBox("Enter a number betweeen 0 to 4")
Index = whichdrive
picDisplay.Print "Hard drive name ", Hard_drive(Index)
picDisplay.Print "Transfer Rate ", Transfer_rate(Index)
picDisplay.Print "Transfer Time ", Transfer_time(Index)
picDisplay.Print "Directory Size ", Directory_size
End Sub

Public Sub Min()
Minimum = 0

If Transfer_time(0) < Minimum Then
Minimum = Transfer_time(0)
Hard_mim = Hard_drive(0)
Transfer_min = Transfer_rate(0)
Else
If Transfer_time(1) < Minimum Then
Minimum = Transfer_time(1)
Hard_mim = Hard_drive(1)
Transfer_min = Transfer_rate(1)
Else
If Transfer_time(2) < Minimum Then
Minimum = Transfer_time(2)
Hard_mim = Hard_drive(2)
Transfer_min = Transfer_rate(2)
Else
If Transfer_time(3) < Minimum Then
Minimum = Transfer_time(3)
Hard_mim = Hard_drive(3)
Transfer_min = Transfer_rate(3)
Else
If Transfer_time(4) < Minimum Then
Minimum = Transfer_time(4)
Hard_mim = Hard_drive(4)
Transfer_min = Transfer_rate(4)
Else
End If
End If
End If
End If
End If

End Sub

Private Sub Fastest_display()
picDisplay.Print "The Fastest Dive is: "; " Hard disk "; Hard_mim; " Transfer Rate "; Transfer_min; " Directory_size"; Directory_size; " Transfer Time "; Minimum
End Sub
groovicus
Try this. Repost your code, except use the code tags this time. When you add your reply, in the row right above the text window, there are some little icons. The one on the far right is a code tag. Click on the number symbol to insert a code tag. Then paste in your code. Then click again to insert a closing code tag.

That way your code is readable. Other than that, since it works for the first three, then you are probably entering the wrong name for the 4th. You should add some sort of code to check and see if the drive even exists before trying to perform operations on it. That else right before all of those endifs doesn't need to be there though. As it stands right now, if your program passes all of the other checks, it is going to get to that final else, and then nothing.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.