VB Code:
Dim abc, xdim, ydim As Long
'but it should be this
Dim abc As Long, xdim As Long, ydim As Long
Without the As Long after each one, VB will make them type variant by default. That could be messing up the API. If GetDC() didn't work, you could try GetWindowDC() as well. You should be releasing that DC when you're done too since it's a common one to the system.
VB Code:
Public Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Sub Command1_Click()
Dim xdim As Long, ydim As Long
Dim hWndDesk As Long, hDCDesk As Long
Dim str As String
hWndDesk = GetDesktopWindow
'get the entire desktop window DC
hDCDesk = GetWindowDC(hWndDesk)
xdim = Val(Text1.Text )
ydim = Val(Text2.Text)
str = "yyyyyyy..."
'the return isn't really important, unless you may want to check it for a possible error return
TextOut hDCDesk, xdim, ydim, str, Len(str)
'release the DC
ReleaseDC hWndDesk, hDCDesk
End Sub