Imports System
Imports System.Collections.Generic
Public Module Module1
Public Sub printElementsOnlyOnce(arr() As Integer)
Dim dict As Dictionary(Of Integer, Integer) = New Dictionary(Of Integer, Integer)
For i As Integer = 0 To arr.Length - 1
If dict.ContainsKey(arr(i)) Then
dict.Remove(arr(i))
End If
dict.Add(arr(i), i)
Next
Dim keys As Object = dict.Keys
For Each n As Integer In keys
Console.Write("{0, 3}", n)
Next
End Sub
Public Sub Main()
Dim arr() As Integer = {5, 9, 1, 7, 8, 1, 9, 0, 3, 9, 9, 5, 5, 5}
printElementsOnlyOnce(arr)
End Sub
End Module
' run:
'
' 5 9 1 7 8 0 3
'