Do you have any more done than that? I ask because the answer is different depending on how things are set up.
If I assume that the AgentID column is a column in the same table that has username and password (which would make sense, as it could easily be either a primary key, or something else), then I would be writing the code something like this (assuming a SQL Server DB):
Using cn As New SQLClient.SQLConnection(some connection string)
Using cmd As SQLClient.SQLCommand = cn.CreateCommand
cmd.CommandText = "SELECT AgentID FROM Users WHERE Username = @p1 AND Password = @p2"
cmd.Parameters.AddWithValue("@p1",some user name)
Dim obj As Object = cmd.ExectueScalar
If Obj Is Not Nothing Then
AgentIDNumber = CInt(obj)
'You got nothing, what do you want to do?
Catch ex As Exception
'Do something here, even if just show a message.