Skip to content

Commit 45d30af

Browse files
Update Usage03.md
1 parent 4716eca commit 45d30af

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

docs/tutorials/Usage03.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ def MyFunction(x, y):
1313

1414
The following VBA code can be used to call this function, taking the input parameters from a worksheet and pasting the outputs back to that sheet.
1515

16-
Sub CallPythonCode()
17-
Set res = Py.Call( _
18-
Py.Module("MyScript"), "MyFunction", _
19-
Py.Dict( _
20-
"x", Sheet1.Range("A1").Value2, _
21-
"y", Sheet1.Range("A2").Value2))
22-
Sheet1.Range("A3").Value2 = Py.Var(Py.GetItem(res, "sum"))
23-
Sheet1.Range("A4:B4").Value2 = Py.Var(Py.GetItem(res, "sorted"))
24-
End Sub
16+
```vb.net
17+
Sub CallPythonCode()
18+
Set res = Py.Call( _
19+
Py.Module("MyScript"), "MyFunction", _
20+
Py.Dict( _
21+
"x", Sheet1.Range("A1").Value2, _
22+
"y", Sheet1.Range("A2").Value2))
23+
Sheet1.Range("A3").Value2 = Py.Var(Py.GetItem(res, "sum"))
24+
Sheet1.Range("A4:B4").Value2 = Py.Var(Py.GetItem(res, "sorted"))
25+
End Sub
26+
```
2527

2628
The calls to `Py.Module` and `Py.Call` have been explained above. Once the result dictionary is obtained from the function, its elements can be accessed using `Py.GetItem`.
2729

0 commit comments

Comments
 (0)