-
Notifications
You must be signed in to change notification settings - Fork 93
VB trivial example
Daniel Frantik edited this page Oct 3, 2019
·
5 revisions
- Add reference to tik4ne dlls/projects/packages (tik4net.dll, tik4net.objects.dll)
- Replace HOST, USER and PASS by your real credentials.
- Try the example:
Imports tik4net
Imports tik4net.Objects
Imports tik4net.Objects.Ip.Firewall
Namespace Test
Public Class MyTest
Public Sub TestMikrotik()
Using connection As ITikConnection = ConnectionFactory.CreateConnection(TikConnectionType.Api_v2)
connection.Open(HOST, USER, PASS)
Dim cmd As ITikCommand = connection.CreateCommand("/system/identity/print")
Dim identity = cmd.ExecuteScalar()
Console.WriteLine("Identity: {0}", identity)
Dim logs = connection.LoadList(Of Log)()
For Each log As Log In logs
Console.WriteLine("{0}[{1}]: {2}", log.Time, log.Topics, log.Message)
Next
Dim fwf = New FirewallFilter() With { _
.Chain = FirewallFilter.ChainType.Forward, _
.Action = FirewallFilter.ActionType.Accept _
}
connection.Save(fwf)
End Using
End Sub
End Class
End Namespace
NOTE: you can use some web online convertes to convert C# to VB.NET. For example this converter: http://converter.telerik.com/