: I am having some problem with some code that worked OK when I
: programmed it on Vista 64 bit edition, but is having problems on a
: machine with Windows XP SP2. I have created some simple code that
: simulates the problem, rather than post my original code which is
: more complicated.
: 'Obtain Monitor Name
: Dim MonitorName As String = Screen.AllScreens(0).DeviceName
: 'Gets rid of the "\\.\" at the start of the name
: Do While MonitorName Like "*\*"
: MonitorName = Microsoft.VisualBasic.Right(MonitorName, Len(MonitorName) - 1)
: 'Display message if Monitor Name is "DISPLAY1"
: If (MonitorName = "DISPLAY1") Then
: MsgBox("Monitor Found", MsgBoxStyle.OkOnly, "Monitor Search")
: End If
: The problem is that the message box in the last line never displays,
: Even though the Monitorname is "DISPLAY1" As expected..
: The problem seems to be coming from the call to
: "Screens.AllScreens(0).DeviceName in the first line. If I obtain the
: value of "DeviceName" by putting my cursor over this bit of code it
: DeviceName = "DISPLAY1
: Notice how there is a quotation mark at the start and none at the
: end. This problem carries over to the MonitorName variable, and
: MonitorName would also be missing the final quotation mark when the
: If Statement is run.
: I am programming with VB.Net Express 2008 edition. On a machine with
: Windows XP SP 2, and the program is using .Net Framework 2.0. I have
: tried switching to .Net Framework 3.0 without any success.
: I suspect this is a bug with something on my machine, rather than
: with my program. Is there another way of obtaining the name of all
: monitors attached to the computer?
: Thank you
Thank you for taking the time to look, however I have solved my problem.
For those that run across the same problem it was simply that VB had inserted Additional Characters in the return value of the DeviceName Property after "DISPLAY1" that didn't show in the box that tells you the current value the variable is holding. I solved it by trimming Characters off the right hand side till the string contained the value I needed