I used this code in getting max number of records in my database hope you got an idea with this:

 Private Sub mainform_Load(sender As Object, e As EventArgs) Handles MyBase.Load

   cmd.Connection = conn
            cmd.CommandText = "SELECT MAX(ColumnName)  FROM [databaseName].[dbo].[tableName]"
            conn.Open()
            dr = cmd.ExecuteReader()
            Do While dr.Read()
                x.Text = x.Text & dr.GetValue(0) & vbTab
            Loop
            dr.Close()
            conn.Close()

End sub