pls help me how to trap invalid procedure call error

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 2872 Views - Last Post: 30 July 2009 - 09:18 PM Rate Topic: -----

#1 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

pls help me how to trap invalid procedure call error

Posted 28 July 2009 - 01:32 AM

i already posted my code no one help me
Is This A Good Question/Topic? 0
  • +

Replies To: pls help me how to trap invalid procedure call error

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: pls help me how to trap invalid procedure call error

Posted 28 July 2009 - 01:49 AM

as we say your code that is in yelow we dont see it !!!
what line do you get the error ? post that and dont make a duplicate post
do you read the replay ?
Was This Post Helpful? 0
  • +
  • -

#3 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 29 July 2009 - 11:21 PM

here are my codes
FOR SAVE
Private Sub cmd_save_Click()
Dim fso As New FileSystemObject
Dim sdate As Date, edate As Date, tlsdate As Date, tledate As Date
On Error GoTo ErrSave

If fso.FileExists(File1.Path & "\" & cmbLot.Text & ".txt") Then

	If Not IsDate(txtefcsdate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txtefcsdate.SetFocus
		Exit Sub
	ElseIf Not IsDate(txtefcedate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txtefesdate.SetFocus
		Exit Sub
	ElseIf Not IsDate(txttlsdate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txttlsdate.SetFocus
		Exit Sub
	ElseIf Not IsDate(txttledate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txttledate.SetFocus
		Exit Sub
	End If
	
	sdate = CDate(Format(txtefcsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	edate = CDate(Format(txtefcedate.Text, "mm/dd/yyyy hh:mm:ss"))
	
	tlsdate = CDate(Format(txttlsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	tledate = CDate(Format(txttledate.Text, "mm/dd/yyyy hh:mm:ss"))
	
	If edate < sdate Then
		MsgBox "EFC End Date is Less Than EFC Start Date!", vbCritical
		txtefcsdate.SetFocus
		Exit Sub
	ElseIf edate = sdate Then
		MsgBox "EFC End Date is Equal to EFC Start Date!", vbCritical
		txtefcsdate.SetFocus
		Exit Sub
	End If
	
	If tledate < tlsdate Then
		MsgBox "TL End Date is Less Than TL Start Date!", vbCritical
		txttlsdate.SetFocus
		Exit Sub
	ElseIf tledate = tlsdate Then
		MsgBox "TL End Date is Equal to TL Start Date!", vbCritical
		txttlsdate.SetFocus
		Exit Sub
	End If
								
	'Check if Exists in Dbase
	If Val(GetData("Select count(*) from AOI_main where mfg_info='" & cmbLot.Text & "'")) >= 1 Then
		Dim msg
		msg = MsgBox("Data Already Exists! Overwrite?", vbYesNo)
		
		If msg = vbYes Then
			Execute_DML ("Delete from AOI_main where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from Dents_data where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from Pits_data where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from BrObject_data where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from DrObject_data where mfg_info='" & cmbLot.Text & "'")
			Me.MousePointer = vbHourglass
			ExtractData (cmbLot.Text)
			Me.MousePointer = vbDefault
		End If
	Else
		Me.MousePointer = vbHourglass
		ExtractData (cmbLot.Text)
		Me.MousePointer = vbDefault
		Me.MousePointer = vbDefault
	End If
Else
	MsgBox "File Not Found!", vbCritical
End If

Exit Sub
ErrSave:
	MsgBox Err.Description, vbCritical
	Err.Clear

End Sub


FOR DATA BASE
Private Sub ExtractData(ByVal Lot As String)
Dim fso As New FileSystemObject
Dim ts As TextStream
Dim str_read As String, mfg_info As String, tlNo As String
Dim tl_len As Double, ctr As Double, dataproc As Boolean
Dim x_val As Double, y_val As Double, x_val2 As Double
Dim dateval, temp, temp2, tothrs, tothrs2, sdate As Date, edate As Date
Dim tlsdate As Date, tledate As Date, dateval2

	
	sdate = CDate(Format(txtefcsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	edate = CDate(Format(txtefcedate.Text, "mm/dd/yyyy hh:mm:ss"))
	
	tlsdate = CDate(Format(txttlsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	tledate = CDate(Format(txttledate.Text, "mm/dd/yyyy hh:mm:ss"))
		
	tothrs = DateDiff("n", sdate, edate)
	tothrs = Round(tothrs / 60, 2)
	
	tothrs2 = DateDiff("n", tlsdate, tledate)
	tothrs2 = Round(tothrs2 / 60, 2)

	Set ts = fso.OpenTextFile(File1.Path & "\" & Lot & ".txt", ForReading)
				  
	Dim defIndex, defName

		defIndex = GetIniFileVal("PROGRAM", "DEF_INDEX")
		defName = Split(GetIniFileVal("PROGRAM", "DEFECTS"), ",")
	
	ctr = 0
	Do While Not ts.AtEndOfStream
		ctr = ctr + 1
		str_read = ts.ReadLine
			  
				
		If InStr(str_read, "Shiny") <> 0 Then
			dataproc = True
		End If
				
		'get data
		If ctr = 4 Then
			'Get Info and TL No
			mfg_info = Split(str_read, "|")(0)
			tlNo = Left(Split(str_read, "|")(1), 1)
		ElseIf ctr = 8 Then
			'get Tl Len
			tl_len = Round(Val(Split(str_read, "|")(0)), 1)
						
			Execute_DML ("Insert into AOI_main (mfg_info,date_start,date_end,f_len,tl_no,tl_sdate,tl_edate) values('" & _
				mfg_info & "','" & sdate & "','" & edate & "'," & tl_len & ",'" & tlNo & "','" & tlsdate & "','" & tledate & "')")
			
		
		ElseIf dataproc Then
			If str_read = "EOV" Then
				Exit Do
			ElseIf CheckIniVal(Split(str_read, "|")(1), defIndex) Then
				Dim code As String, def_code As String
				
				code = Split(str_read, "|")(1)
											
				def_code = defName(code - 1)
			
				''' true dates
				x_val = Round(Val(Split(str_read, "|")(4)), 1)
				x_val2 = Round(tl_len - x_val, 1)
				y_val = Round(Val(Split(str_read, "|")(9)), 1)
								
				temp = (x_val2 / tl_len) * tothrs
				temp2 = temp
				
				dateval = DateAdd("h", Val(Round(temp, 0)), sdate)
				temp = temp2 - Round(temp, 0)
				temp = temp * 60
				dateval = DateAdd("n", Val(temp), dateval)
				''''''''''==================
				
				temp = 0: temp2 = 0
				temp = (x_val / tl_len) * tothrs2
				temp2 = temp
				dateval2 = DateAdd("h", Val(Round(temp, 0)), tlsdate)
				temp = temp2 - Round(temp, 0)
				temp = temp * 60
				dateval2 = DateAdd("n", Val(temp), dateval2)
				'''end true dates
				
				If InStr(LCase(def_code), "dent") Then
					Execute_DML ("Insert into Dents_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & dateval & "','" & def_code & "','" & dateval2 & "'," & x_val2 & ")")
				ElseIf InStr(LCase(def_code), "pit") Then
					Execute_DML ("Insert into Pits_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & dateval & "','" & def_code & "','" & dateval2 & "'," & x_val2 & ")")
				ElseIf InStr(LCase(def_code), "bright object") Then
					Execute_DML ("Insert into BrObject_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & date_val & "','" & def_code & "','" & date_val2 & "'," & x_val2 & ")")
				ElseIf InStr(LCase(def_code), "dark object") Then
					Execute_DML ("Insert into DrObject_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & date_val & "','" & def_code & "','" & date_val2 & "'," & x_val2 & ")")
				End If
			End If
		End If
		
	Loop
	ts.Close
	

	
	'create archiving folder & copy processed file to the archived folder
	If Not fso.FolderExists(File1.Path & "\" & Mid(mfg_info, 8, 1)) Then fso.CreateFolder File1.Path & "\" & Mid(mfg_info, 8, 1)
	fso.CopyFile File1.Path & "\" & cmbLot.Text & ".txt", File1.Path & "\" & Mid(mfg_info, 8, 1) & "\"
	Kill File1.Path & "\" & Lot & ".txt"
	
	FillLotNo
	MsgBox "Record Saved!"
	Me.SetFocus
End Sub


there are no yellow line error it just pop up and hangs
Was This Post Helpful? 0
  • +
  • -

#4 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 29 July 2009 - 11:28 PM

View Postrenmee, on 29 Jul, 2009 - 10:21 PM, said:

here are my codes
FOR SAVE
Private Sub cmd_save_Click()
Dim fso As New FileSystemObject
Dim sdate As Date, edate As Date, tlsdate As Date, tledate As Date
On Error GoTo ErrSave

If fso.FileExists(File1.Path & "\" & cmbLot.Text & ".txt") Then

	If Not IsDate(txtefcsdate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txtefcsdate.SetFocus
		Exit Sub
	ElseIf Not IsDate(txtefcedate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txtefesdate.SetFocus
		Exit Sub
	ElseIf Not IsDate(txttlsdate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txttlsdate.SetFocus
		Exit Sub
	ElseIf Not IsDate(txttledate.Text) Then
		MsgBox "Invalid Date Format", vbInformation
		txttledate.SetFocus
		Exit Sub
	End If
	
	sdate = CDate(Format(txtefcsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	edate = CDate(Format(txtefcedate.Text, "mm/dd/yyyy hh:mm:ss"))
	
	tlsdate = CDate(Format(txttlsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	tledate = CDate(Format(txttledate.Text, "mm/dd/yyyy hh:mm:ss"))
	
	If edate < sdate Then
		MsgBox "EFC End Date is Less Than EFC Start Date!", vbCritical
		txtefcsdate.SetFocus
		Exit Sub
	ElseIf edate = sdate Then
		MsgBox "EFC End Date is Equal to EFC Start Date!", vbCritical
		txtefcsdate.SetFocus
		Exit Sub
	End If
	
	If tledate < tlsdate Then
		MsgBox "TL End Date is Less Than TL Start Date!", vbCritical
		txttlsdate.SetFocus
		Exit Sub
	ElseIf tledate = tlsdate Then
		MsgBox "TL End Date is Equal to TL Start Date!", vbCritical
		txttlsdate.SetFocus
		Exit Sub
	End If
								
	'Check if Exists in Dbase
	If Val(GetData("Select count(*) from AOI_main where mfg_info='" & cmbLot.Text & "'")) >= 1 Then
		Dim msg
		msg = MsgBox("Data Already Exists! Overwrite?", vbYesNo)
		
		If msg = vbYes Then
			Execute_DML ("Delete from AOI_main where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from Dents_data where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from Pits_data where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from BrObject_data where mfg_info='" & cmbLot.Text & "'")
			Execute_DML ("Delete from DrObject_data where mfg_info='" & cmbLot.Text & "'")
			Me.MousePointer = vbHourglass
			ExtractData (cmbLot.Text)
			Me.MousePointer = vbDefault
		End If
	Else
		Me.MousePointer = vbHourglass
		ExtractData (cmbLot.Text)
		Me.MousePointer = vbDefault
		Me.MousePointer = vbDefault
	End If
Else
	MsgBox "File Not Found!", vbCritical
End If

Exit Sub
ErrSave:
	MsgBox Err.Description, vbCritical
	Err.Clear

End Sub


FOR DATA BASE
Private Sub ExtractData(ByVal Lot As String)
Dim fso As New FileSystemObject
Dim ts As TextStream
Dim str_read As String, mfg_info As String, tlNo As String
Dim tl_len As Double, ctr As Double, dataproc As Boolean
Dim x_val As Double, y_val As Double, x_val2 As Double
Dim dateval, temp, temp2, tothrs, tothrs2, sdate As Date, edate As Date
Dim tlsdate As Date, tledate As Date, dateval2

	
	sdate = CDate(Format(txtefcsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	edate = CDate(Format(txtefcedate.Text, "mm/dd/yyyy hh:mm:ss"))
	
	tlsdate = CDate(Format(txttlsdate.Text, "mm/dd/yyyy hh:mm:ss"))
	tledate = CDate(Format(txttledate.Text, "mm/dd/yyyy hh:mm:ss"))
		
	tothrs = DateDiff("n", sdate, edate)
	tothrs = Round(tothrs / 60, 2)
	
	tothrs2 = DateDiff("n", tlsdate, tledate)
	tothrs2 = Round(tothrs2 / 60, 2)

	Set ts = fso.OpenTextFile(File1.Path & "\" & Lot & ".txt", ForReading)
				  
	Dim defIndex, defName

		defIndex = GetIniFileVal("PROGRAM", "DEF_INDEX")
		defName = Split(GetIniFileVal("PROGRAM", "DEFECTS"), ",")
	
	ctr = 0
	Do While Not ts.AtEndOfStream
		ctr = ctr + 1
		str_read = ts.ReadLine
			  
				
		If InStr(str_read, "Shiny") <> 0 Then
			dataproc = True
		End If
				
		'get data
		If ctr = 4 Then
			'Get Info and TL No
			mfg_info = Split(str_read, "|")(0)
			tlNo = Left(Split(str_read, "|")(1), 1)
		ElseIf ctr = 8 Then
			'get Tl Len
			tl_len = Round(Val(Split(str_read, "|")(0)), 1)
						
			Execute_DML ("Insert into AOI_main (mfg_info,date_start,date_end,f_len,tl_no,tl_sdate,tl_edate) values('" & _
				mfg_info & "','" & sdate & "','" & edate & "'," & tl_len & ",'" & tlNo & "','" & tlsdate & "','" & tledate & "')")
			
		
		ElseIf dataproc Then
			If str_read = "EOV" Then
				Exit Do
			ElseIf CheckIniVal(Split(str_read, "|")(1), defIndex) Then
				Dim code As String, def_code As String
				
				code = Split(str_read, "|")(1)
											
				def_code = defName(code - 1)
			
				''' true dates
				x_val = Round(Val(Split(str_read, "|")(4)), 1)
				x_val2 = Round(tl_len - x_val, 1)
				y_val = Round(Val(Split(str_read, "|")(9)), 1)
								
				temp = (x_val2 / tl_len) * tothrs
				temp2 = temp
				
				dateval = DateAdd("h", Val(Round(temp, 0)), sdate)
				temp = temp2 - Round(temp, 0)
				temp = temp * 60
				dateval = DateAdd("n", Val(temp), dateval)
				''''''''''==================
				
				temp = 0: temp2 = 0
				temp = (x_val / tl_len) * tothrs2
				temp2 = temp
				dateval2 = DateAdd("h", Val(Round(temp, 0)), tlsdate)
				temp = temp2 - Round(temp, 0)
				temp = temp * 60
				dateval2 = DateAdd("n", Val(temp), dateval2)
				'''end true dates
				
				If InStr(LCase(def_code), "dent") Then
					Execute_DML ("Insert into Dents_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & dateval & "','" & def_code & "','" & dateval2 & "'," & x_val2 & ")")
				ElseIf InStr(LCase(def_code), "pit") Then
					Execute_DML ("Insert into Pits_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & dateval & "','" & def_code & "','" & dateval2 & "'," & x_val2 & ")")
				ElseIf InStr(LCase(def_code), "bright object") Then
					Execute_DML ("Insert into BrObject_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & date_val & "','" & def_code & "','" & date_val2 & "'," & x_val2 & ")")
				ElseIf InStr(LCase(def_code), "dark object") Then
					Execute_DML ("Insert into DrObject_data (mfg_info,x_val,y_val,date_val,def_cat,tl_dateval,efc_xval) values('" & _
						mfg_info & "'," & x_val & "," & y_val & ",'" & date_val & "','" & def_code & "','" & date_val2 & "'," & x_val2 & ")")
				End If
			End If
		End If
		
	Loop
	ts.Close
	

	
	'create archiving folder & copy processed file to the archived folder
	If Not fso.FolderExists(File1.Path & "\" & Mid(mfg_info, 8, 1)) Then fso.CreateFolder File1.Path & "\" & Mid(mfg_info, 8, 1)
	fso.CopyFile File1.Path & "\" & cmbLot.Text & ".txt", File1.Path & "\" & Mid(mfg_info, 8, 1) & "\"
	Kill File1.Path & "\" & Lot & ".txt"
	
	FillLotNo
	MsgBox "Record Saved!"
	Me.SetFocus
End Sub


there are no yellow line error it just pop up and hangs

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#5 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: pls help me how to trap invalid procedure call error

Posted 29 July 2009 - 11:36 PM

debug it step by step untill you get the error. then you will know where is that function
Was This Post Helpful? 0
  • +
  • -

#6 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 12:04 AM

remove or comment the
on error statement
now run it

Quote

it's not the solution , it's just take you where the error occurred

This post has been edited by thava: 30 July 2009 - 12:05 AM

Was This Post Helpful? 0
  • +
  • -

#7 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 12:51 AM

this is my error statement

dateval = DateAdd("h", Val(Round(temp, 0)), sdate)

thnx guys for helping..
i dont know what seems to be the problem..
if its the database or the code
Was This Post Helpful? 0
  • +
  • -

#8 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 12:59 AM

the runtime error "5" is invalid procedure call or arguement
Was This Post Helpful? 0
  • +
  • -

#9 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 01:07 AM

well
Function Val(String As String) As Double
you must send a string but you send it
Function Round(Number, [NumDigitsAfterDecimal As Long])
that return decimal

i am not sure try remuving val function or use CStr(Round(temp, 0))

This post has been edited by NoBrain: 30 July 2009 - 01:09 AM

Was This Post Helpful? 0
  • +
  • -

#10 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 01:11 AM

remove the whole val function? or just in the error line?
Was This Post Helpful? 0
  • +
  • -

#11 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 01:15 AM

ok try this
dateval = DateAdd("h", Val(cstr(Round(temp, 0))), sdate)



not sure if that will work let me try it first

This post has been edited by NoBrain: 30 July 2009 - 01:17 AM

Was This Post Helpful? 0
  • +
  • -

#12 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 01:16 AM

thnx for your quick replies no brain.. but it seems that the problem still persist... what do u think i should do with this code
Was This Post Helpful? 0
  • +
  • -

#13 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 01:23 AM

oki sir i tried it, it has still the same error, or should i change the values to CStr too, to comprehend other values?
Was This Post Helpful? 0
  • +
  • -

#14 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 01:23 AM

you know what it dont give error to me :o
Was This Post Helpful? 0
  • +
  • -

#15 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: pls help me how to trap invalid procedure call error

Posted 30 July 2009 - 01:32 AM

if it wasnt the code do you think its in the database? im using (DAO) ms access

i just reloaded the program and that error was solved but subscript out of range occur in this line
def_code = defName(code - 1)

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2