I
Ian Rutherford
Heya guys,
It seems VB .net no longer supports the awesome ability of VB 6 to declare
something as a string and specify how long the string would be all in one
line:
Public myString as String * 32 'this would make it 32 characters long
Apparently the VB .net conversion is to do this:
Public myString as String
myString = new String(CChar(" "), 32) 'this creates a string with
32 blank spots in it
My problem lies in these facts:
a) You can't use this technique in Structures, which is where I absolutely
must use it.
b) Trying to say Public svDevice = new String(CChar(" "), 32) results in
VB saying that "svDevice" needs to be a constant for this to be allowed.
Unfortunately, I can't set this to a const because it needs to be changed.
Background:
I'm calling from the Windows GDI Platform SDK this: Private Declare
Function GetMonitorInfo Lib "User32.dll" Alias "GetMonitorInfoA" (ByVal
hMonitor As Integer, ByRef lpMI As MonitorInfoEx) As Integer
and the Structure that I have to hold each monitor's info is:
Private Structure MonitorInfoEx
Public cbSize As Integer
Public rcMonitor As RectAPI
Public rcWork As RectAPI
Public dwFlags As Integer
Public szDevice As String <<=== that has to be 32 characters long
End Structure
So basically, because VB .net doesn't support String-length pre-defining the
way I need it to, I can't use GetMonitorInfo or anything like it. Does
anyone know of this problem and how I can work around it? Thanks!!!
Ian
It seems VB .net no longer supports the awesome ability of VB 6 to declare
something as a string and specify how long the string would be all in one
line:
Public myString as String * 32 'this would make it 32 characters long
Apparently the VB .net conversion is to do this:
Public myString as String
myString = new String(CChar(" "), 32) 'this creates a string with
32 blank spots in it
My problem lies in these facts:
a) You can't use this technique in Structures, which is where I absolutely
must use it.
b) Trying to say Public svDevice = new String(CChar(" "), 32) results in
VB saying that "svDevice" needs to be a constant for this to be allowed.
Unfortunately, I can't set this to a const because it needs to be changed.
Background:
I'm calling from the Windows GDI Platform SDK this: Private Declare
Function GetMonitorInfo Lib "User32.dll" Alias "GetMonitorInfoA" (ByVal
hMonitor As Integer, ByRef lpMI As MonitorInfoEx) As Integer
and the Structure that I have to hold each monitor's info is:
Private Structure MonitorInfoEx
Public cbSize As Integer
Public rcMonitor As RectAPI
Public rcWork As RectAPI
Public dwFlags As Integer
Public szDevice As String <<=== that has to be 32 characters long
End Structure
So basically, because VB .net doesn't support String-length pre-defining the
way I need it to, I can't use GetMonitorInfo or anything like it. Does
anyone know of this problem and how I can work around it? Thanks!!!
Ian