Hi,
I am pretty new to Ilogic, an experimenting a bit.
Can this code be simpler ?
If GoExcel.CellValue(ExcelFile, "Sheet1", "A1")=1 Then Component.IsActive("A1") = True Else Component.IsActive("A1") = False End If If GoExcel.CellValue(ExcelFile, "Sheet1", "B1")=1 Then Component.IsActive("B1") = True Else Component.IsActive("B1") = False End If If GoExcel.CellValue(ExcelFile, "Sheet1", "C1")=1 Then Component.IsActive("C1") = True Else Component.IsActive("C1") = False End If
In general, (almost) everytime you have a if/else if can be replaced (on the syntax level).
So this:
If GoExcel.CellValue(ExcelFile, "Sheet1", "A1")=1 Then
Component.IsActive("A1") = True
Else
Component.IsActive("A1") = False
End If
Can be this:
Dim b as Boolean = (GoExcel.CellValue(ExcelFile, "Sheet1", "A1")=1)
Component.IsActive("A1") = b = Not b
But it's up to you...
I used to do this (in VBA)...
Dim int_charCode As Integer For int_charCode = 65 To 67 'Loop 'A' to 'C' Component.IsActive(Chr(int_charCode) & "1") = IIf(ws_test.Range(Chr(int_charCode) & "1").Value = 1, True, False) Next
iLogic....
Dim int_charCode As Integer = 65 For int_charCode = 65 To 67 Component.IsActive(ChrW(int_charCode) & "1") = If( GoExcel.CellValue("D:\TestiLogic.xlsx", "Sheet1", ChrW(int_charCode) & "1") = 1, True, False) Next
Augusto, can you explain the extra "= Not b" on your last line? I don't understand.
Edit: Unless you were simply showing how one could also use Not b to set visiblity to the opposite of the test case
Sorry that 'Not b' is not required... some copy/paste mistake... 🙂