Screen.LastScreenIndex

From Xojo Documentation

Read-Only Property (As Integer )
IntegerValue = aScreen.LastScreenIndex

New in 2019r2

Supported for all project types and targets.

The index of the last screen connected to the user's computer. Screen 0 is the main screen.This can be useful when you need to loop through the user's screens.

Example

This example finds the maximum screen depth of all screens connected to the user's computer:

Var maxDepth As Integer
For i As Integer = 0 To Screen.LastScreenIndex
Var currentScreenDepth As Integer
currentScreenDepth = ScreenAt(i).ColorDepth
If currentScreenDepth > maxDepth Then
maxDepth = currentScreenDepth
End If
Next