Message 1 of 11

Not applicable
06-14-2018
03:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I wrote a rule to retrieve values from parameters, but if the parameters doesn't not exist from the model. The program complain and won't run. How can I bypass if the parameters does't not exist.
Following is the code:
SyntaxEditor Code Snippet
'Extract Information from the part to a text file 'My.Computer.FileSystem.WriteAllText("C:\TestFolder1\test.txt", Title + vbNewLine + Mfg + vbNewLine+ Mfg_no+ vbNewLine + SuggestedVendor +vbNewLine + SuggestedVendorPartNumber + vbNewLine + DST_Cost ,True 'part_Number = iProperties.Value("Project", "Part Number") Dim part_Number As String Dim part_Revision As String Dim sFileName As String Dim tabs As String = "ITEM QTY PART_NO DESCRIPTION REFERENCE" Dim sp As String = " " Dim fFile As IO.File Dim pTitle As String Dim pMfg As String Dim pMfg_no As String Dim pSuggestedVendor As String Dim pSuggestedVendorPartNumber As String Dim pDST_Cost As String part_Number = ThisDoc.FileName part_Revision = iProperties.Value("Project", "Revision Number") If iProperties.Value("Custom", "Title") = Isempty Then pTitle = Isempty Else pTitle = iProperties.Value("Custom", "Title") End If If (iProperties.Value("Custom", "Mfg")) = Isempty Then pMfg = Isempty Else pMfg = iProperties.Value("Custom", "Mfg") End If If (iProperties.Value("Custom", "Mfg_no")) = Isempty Then pMfg_no = Isempty Else pMfg_no = iProperties.Value("Custom", "Mfg_no") End If If (iProperties.Value("Custom", "SuggestedVendor")) = Isempty Then pSuggestedVendor = Isempty Else pSuggestedVendor = iProperties.Value("Custom", "SuggestedVendor") End If If (iProperties.Value("Custom", "SuggestedVendorPartNumber")) = Isempty Then pSuggestedVendorPartNumber = Isempty Else pSuggestedVendorPartNumber = iProperties.Value("Custom", "SuggestedVendorPartNumber") End If If (iProperties.Value("Custom", "DST_Cost")) = Isempty Then pDST_Cost = Isempty Else pDST_Cost = iProperties.Value("Custom", "DST_Cost") End If My.Computer.FileSystem.WriteAllText("C:\TestFolder1\"+part_Number+"_R0"+part_Revision+".txt", tabs +vbNewLine +"1"+sp+ pTitle + vbNewLine +"2"+sp+ pMfg + vbNewLine +"3"+sp+pMfg_no+vbNewLine+"4"+sp+ iProperties.Value("Custom", "SuggestedVendor") +vbNewLine +"5"+sp+iProperties.Value("Custom", "SuggestedVendorPartNumber") + vbNewLine +"6"+sp+ iProperties.Value("Custom", "DST_Cost") ,True, System.Text.Encoding.ASCII) iLogicVb.UpdateWhenDone = True
Solved! Go to Solution.