Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Need Help With Vb


  • Please log in to reply
1 reply to this topic

#1 Cunny

Cunny

  • Members
  • 1 posts
  • OFFLINE
  •  
  • Local time:08:52 PM

Posted 24 April 2006 - 01:21 PM

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

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:52 PM

Posted 24 April 2006 - 03:40 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users