i = GoExcel.FindRow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I know this probably isn't the cleanest way to do this but i am very novice to ilogic and i at least understand what's going on
Dim partNumber As String = iProperties.Value("Project", "Part Number") partNumber = partNumber.Trim().ToUpper() i = GoExcel.FindRow("P:\_MASTER_PART_LIST\MASTER_PART_LIST.xls", "MASTER_PART_LIST", "Part No.", "=", partNumber) If i <> -1 iProperties.Value("Project", "Description") = GoExcel.CurrentRowValue("Description") iProperties.Value("Project", "Vendor") = GoExcel.CurrentRowValue("Manufacturer") Dim partDescription As String = iProperties.Value("Project", "Description") partDescription = partDescription.ToUpper() iProperties.Value("Project", "Description")= partDescription Dim partVendor As String = iProperties.Value("Project", "Vendor") partVendor = partVendor.ToUpper() iProperties.Value("Project", "Vendor")= partVendor Else iProperties.Value("Project", "Description") = "The entered Part Number does not exist in the Master Parts List" iProperties.Value("Project", "Vendor") = "The entered Part Number does not exist in the Master Parts List" End If
I am going to be adding more If statements for different scenarios, right now the else is there if the part number is not found in the excel look up. what is this function called " i <> -1"? didn't find much trying to google it. I am looking to hopefully use the "i" instead of a else statement because i am going to have a few if statements that would include if the look up cant find the part number.
This is my work in progress
Dim oDoc As Document oDoc = ThisDoc.Document 'define list of custom properties to delete Dim MyArrayList As New ArrayList MyArrayList.Add("Part_Number_1") MyArrayList.Add("Part_Number_2") MyArrayList.Add("Part_Number_3") MyArrayList.Add("Part_Number_4") MyArrayList.Add("Part_Number_5") 'define custom property collection oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties") '[ Adds custom properties For Each oItem In MyArrayList oFlag = False 'set flag to default value 'look at each property in the collection For Each oCustProp In oCustomPropertySet 'check property name against the list item If oItem = oCustProp.Name Then oFlag = True 'trip the flag End If Next If oFlag = False Then 'Create new iProperty iProperties.Value(oDoc, "Custom", oItem ) = "" End If Next '] '[ Erases custom properties For Each oCustProp In oCustomPropertySet oFlag = False 'set flag to default value For Each oItem In MyArrayList 'check property name against the list item If oCustProp.Name = oItem Then oFlag = True 'trip the flag End If Next If oFlag = False Then 'delete property oCustProp.Delete End If Next '] '[ If 1-5 are Blank and a Part Number is Found If iProperties.Value("Custom", "Part_Number_1") = "" And iProperties.Value("Custom", "Part_Number_2") = "" And iProperties.Value("Custom", "Part_Number_3") = "" And iProperties.Value("Custom", "Part_Number_4") = "" And iProperties.Value("Custom", "Part_Number_5") = "" And i <> -1 Dim partNumber As String = iProperties.Value("Project", "Part Number") partNumber = partNumber.Trim().ToUpper() i = GoExcel.FindRow("P:\_MASTER_PART_LIST\MASTER_PART_LIST.xls", "MASTER_PART_LIST", "Part No.", "=", partNumber) iProperties.Value("Project", "Description") = GoExcel.CurrentRowValue("Description") iProperties.Value("Project", "Vendor") = GoExcel.CurrentRowValue("Manufacturer") Dim partDescription As String = iProperties.Value("Project", "Description") partDescription = partDescription.ToUpper() iProperties.Value("Project", "Description")= partDescription Dim partVendor As String = iProperties.Value("Project", "Vendor") partVendor = partVendor.ToUpper() iProperties.Value("Project", "Vendor") = partVendor '] '[ If 2-5 are Blank and a Part Number is Found Else If iProperties.Value("Custom", "Part_Number_2") = "" And iProperties.Value("Custom", "Part_Number_3") = "" And iProperties.Value("Custom", "Part_Number_4") = "" And iProperties.Value("Custom", "Part_Number_5") = "" And i <> -1 Dim partNumber1 As String = iProperties.Value("Custom", "Part_Number_1") partNumber1 = partNumber1.Trim().ToUpper() i = GoExcel.FindRow("P:\_MASTER_PART_LIST\MASTER_PART_LIST.xls", "MASTER_PART_LIST", "Part No.", "=", partNumber1) iProperties.Value("Project", "Description") = GoExcel.CurrentRowValue("Description") iProperties.Value("Project", "Vendor") = GoExcel.CurrentRowValue("Manufacturer") Dim partDescription1 As String = iProperties.Value("Project", "Description") partDescription1 = partDescription1.ToUpper() iProperties.Value("Project", "Description")= partDescription1 Dim partVendor1 As String = iProperties.Value("Project", "Vendor") partVendor1 = partVendor1.ToUpper() iProperties.Value("Project", "Vendor") = partVendor1 iProperties.Value("Project", "Part Number") = partNumber1 ']
I would want that if Part Number 3-5 are blank them take Part number 1 and 2 then combine them into one line to replace the Part Number in the properties. Then take those two part numbers and combine the descriptions and manufacturers into their own lines respectively. So I don't think I can just use a else statement if the look up cant find the part number in the excel but what if it cant find Part Number 1 or Part Number 2? It would require two else statements which I am not able to do.
I understand how to combine the two the text into a line, its just the different scenarios where a part number is not found
Like what if I have two if statements where Part number 1 is found but Part Number 2 isn't and vice versa, so a else statement would work because 2 of those would be separate If statements and a all encompassing Else statement wouldn't work
Any recommendations of what I can do here, and I hope it explained it properly.