Easy question for Save AS code

Easy question for Save AS code

Christy.Tuan
Participant Participant
381 Views
2 Replies
Message 1 of 3

Easy question for Save AS code

Christy.Tuan
Participant
Participant

Hello there, I just start to learn VB. I think i have a very easy question for the code masters.

I want to create a SAVE AS button in the ilogic form. I almost success, but I have a problem with data type. 

My code is as follows:

	InventorVb.DocumentUpdate()
        ThisDoc.Save

	Dim NewFileName
	Dim CurrentFileName = ThisDoc.FileName(False) 'without extension
	Dim oPath = "H:\PROJETS\"
	Dim NoContrat = iProperties.Value("Custom", "No. Contrat")
	
	NewFileName = InputBox(CurrentFileName + " Save As","Piece Save As")
	
	If NewFileName <> 0 Then
		
		ThisDoc.Document.SaveAs(oPath & NoContrat & "-" & NewFileName & ".ipt", True)
		

	End If

 I put this on my ilogic form, and type the new piece name, but it shows the type are wrong.

ChristyTuan_0-1642560837179.png 

ChristyTuan_1-1642560854800.png

ERROR says: Conversion of string "R610620A01-002" to type 'Double' is not valid.

It works if I just type numbers like "12345". I know it might the problem with the inputbox, but I don't know how to correct it😂

 

Looking forward to the replys! Thanks!!!!

0 Likes
Accepted solutions (1)
382 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor
Accepted solution

You will need to determine if the string is empty. At the moment you are using integer  value which is incorrect for String you are working with

 

If NewFileName <> "" Then

'DO SAVING
Else
MessageBox.Show("Exiting Save","iLogic")
End If

 And here is other methods of working with input box buttons

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

Christy.Tuan
Participant
Participant
It works perfectly! And thanks for the additional info!!
0 Likes