4 Replies - 1833 Views - Last Post: 16 December 2008 - 01:15 PM Rate Topic: -----

#1 byru  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-December 08

run time error '13' of type mismatch

Posted 16 December 2008 - 07:56 AM

Dim process(11) As Integer
Dim priority(11) As Integer
Dim gantt(12) As Integer
Dim r As Integer
Dim x As Integer

Private Sub cmdAdd_Click()
r = InputBox("Please enter the number of Process:")
For x = 1 To r
process(x) = InputBox("Enter CPU Time for P" & (x), "Algorithm")
priority(x) = InputBox("Enter Priority " & (x), "Algorithm")
lstProcess.AddItem "P" & (x)
lstCPUtime.AddItem process(x)
lstPriority.AddItem priority(x)
Next x
If r > 10 Then
MsgBox ("Sorry, limited to 10 process only!")
End
End If
End Sub

Private Sub cmdCompute_Click()
'FCFS
If Combo1.ListIndex = 0 Then
For i = 0 To lstProcess.ListCount
lblgantt(i).Caption = lstProcess.List(i)
lstPro.AddItem lstProcess.List(i)
Next i
lblprocess(0).Caption = 0
For i = 1 To lstCPUtime.ListCount
lblprocess(i) = Val(lblprocess(i - 1)) + Val(lstCPUtime.List(i - 1))
Next i
wt = 0
tt = 0
For i = 0 To lstCPUtime.ListCount
	If i < lstCPUtime.ListCount Then
		lstWT.AddItem lblprocess(i) 'waiting time
		wt = wt + Val(lblprocess(i))
	End If
		lstTA.AddItem lblprocess(i + 1) 'turn around time
		tt = tt + Val(lblprocess(i + 1))
		Next i
		'Display result
		
Text1 = Format(wt / lstProcess.ListCount, "#.00")
Text2 = Format(tt / lstProcess.ListCount, "#.00")

'SJF
 ElseIf Combo1.ListIndex = 1 Then
 'swapping
For i = 0 To lstCPUtime.ListCount - 1
	For j = i + 1 To lstCPUtime.ListCount - 1

		If Val(lstCPUtime.List(i)) > Val(lstCPUtime.List(j)) Then
		'cpu time
		r = lstCPUtime.List(i)
		lstCPUtime.List(i) = lstCPUtime.List(j)
		lstCPUtime.List(j) = r
		
		'process
		r = lstProcess.List(i)
		lstProcess.List(i) = lstProcess.List(j)
		lstProcess.List(j) = r
		End If
		Next j
		 Next i
		
		For i = 0 To lstProcess.ListCount
			lblgantt(i).Caption = lstProcess.List(i)
			lstPro.AddItem lstProcess.List(i)
			Next i
			
			lblprocess(0).Caption = 0
			For i = 1 To lstCPUtime.ListCount
			lblprocess(i) = Val(lblprocess(i - 1)) + Val(lstCPUtime.List(i - 1))
			Next i
			
			wt = 0
			tt = 0
			For i = 0 To lstCPUtime.ListCount
			If i < lstCPUtime.ListCount Then
			lstWT.AddItem lblprocess(i) 'waiting time
			wt = wt + Val(lblprocess(i))
				End If
			
			lstTA.AddItem lblprocess(i + 1) 'turn around time
			tt = tt + Val(lblprocess(i + 1))
			Next i
			
			'display result
		  Text1 = Format(wt / lstProcess.ListCount, "#.00")
		  Text2 = Format(tt / lstProcess.ListCount, "#.00")
  
  Else
  'PRIORITY
  'swapping
  For i = 0 To lstCPUtime.ListCount - 1
	For j = i + 1 To lstCPUtime.ListCount - 1
		If Val(lstPriority.List(i)) < Val(lstPriority.List(j)) Then
		
		'cput time
		r = lstCPUtime.List(i)
		lstCPUtime.List(i) = lstCPUtime.List(j)
		lstCPUtime.List(j) = r

		'process
		r = lstProcess.List(i)
		lstProcess.List(i) = lstProcess.List(j)
		lstProcess.List(j) = r
		
		'priority
		r = lstPriority.List(i)
		lstPriority.List(i) = lstPriority.List(j)
		lstPriority.List(j) = r
		End If
		Next j
		Next i
		
		For i = 0 To lstProcess.ListCount
		lblgantt(i).Caption = lstProcess.List(i)
		lstPro.AddItem lstProcess.List(i)
		Next i
		
		lblprocess(0).Caption = 0
		For i = 1 To lstCPUtime.ListCount
		lblprocess(i) = Val(lblprocess(i - 1)) + Val(lstCPUtime.List(i - 1))
		Next i
		
		wt = 0
		tt = 0
		For i = 0 To lstCPUtime.ListCount
			If i < lstCPUtime.ListCount Then
			lstWT.AddItem lblprocess(i) 'waiting time
			wt = wt + Val(lblprocess(i))
			End If
			
			lstTA.AddItem lblprocess(i + 1) 'turn around time
			tt = tt + Val(lblprocess(i + 1))
			Next i
			
			'display result
			Text1 = Format(wt / lstProcess.ListCount, "#.00")
			Text2 = Format(tt / lstProcess.ListCount, "#.00")
  
			
End If
End Sub

Private Sub Command1_Click()
'Val(lstProcess(0)) = Val(lstCPUtime.List(0))
'For i = 1 To lstProcess.ListCount - 1
'Val(lstProcess(i)) = Val(lstCPUtime.List(i)) + Val(lstProcess(i - 1))
'Next i
'For j = 0 To lstProcess.ListCount - 1
'lblprocess(j + 1).Caption = Val(lstProcess(j))
'lblgantt(j).Caption = lstProcess.List(j)
'Next j







End Sub

Private Sub Form_Load()
ctr = 1
End Sub





sir, that is my project in CPU scheduling the firs-come first-serve, shortest job first, and the priority, but seems it still have a run time error '13' of type mismatch, please help me, i was doing it for many nights please help me i want to pass my subject



***edited font size***
--jjsaw5

Is This A Good Question/Topic? 0
  • +

Replies To: run time error '13' of type mismatch

#2 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

Re: run time error '13' of type mismatch

Posted 16 December 2008 - 08:01 AM

[rules][/rules]




There is absolutley no reason you need to use that font size.
Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: run time error '13' of type mismatch

Posted 16 December 2008 - 08:43 AM

Modified title to be more descriptive of the problem.
Was This Post Helpful? 0
  • +
  • -

#4 byru  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-December 08

Re: run time error '13' of type mismatch

Posted 16 December 2008 - 08:46 AM

can anybody help?
Was This Post Helpful? 0
  • +
  • -

#5 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

Re: run time error '13' of type mismatch

Posted 16 December 2008 - 01:15 PM

View Postbyru, on 16 Dec, 2008 - 10:46 AM, said:

can anybody help?



Have patience, someone will help you when they have time.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1