-1

I am building a POS software using visual basic and trying to display the customer screen on the customer facing screen.

device used is APT 200 series - touch screen POS

i have created a customer form and used the following code in the main form load event

        Dim secondaryDisplay As Screen = Screen.AllScreens(1)

        'Create a new form for the secondary display
        Dim customerscreen As New Form()

        'Set the form's properties to display on the secondary display
        customerscreen.StartPosition = FormStartPosition.Manual
        customerscreen.Location = secondaryDisplay.Bounds.Location
        customerscreen.WindowState = FormWindowState.Maximized
        customerscreen.FormBorderStyle = FormBorderStyle.None

        'Show the form on the secondary display
        customerscreen.Show()

but showing the following error in the following line

Dim secondaryDisplay As Screen = Screen.AllScreens(1)

Index was outside the bounds of the array.

can anyone help on this

AjKu
  • 47
  • 12
  • 1
    It's unclear what version of Windows that you're using, but have you configured Windows to extend the display? See [Set up dual monitors on Windows](https://support.microsoft.com/en-us/windows/set-up-dual-monitors-on-windows-3d5c15dc-cc63-d850-aeb6-b41778147554) and [How to use multiple monitors in Windows](https://support.microsoft.com/en-us/windows/how-to-use-multiple-monitors-in-windows-329c6962-5a4d-b481-7baa-bec9671f728a) – Tu deschizi eu inchid May 07 '23 at 16:40

1 Answers1

3

It means that it does not detect a secondary monitor. The array returned contains only 1 monitor. That is why you have the Index was outside the bounds of the array. error.

I suggest you to check the length of the array before trying to get the second screen. If the array contains only 1 item, that means you can't pick a second screen value.

Maxime Baker
  • 250
  • 1
  • 1
  • 10