Ошибка с типами данных - VB

Узнай цену своей работы

Формулировка задачи:

Давно на бейсике не программировал, нашёл старый код и не могу понять почему не работает (P.s. написал за пару минут не ругайте, да да слепил из готового).
Листинг программы
  1. Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
  2. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  3. Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
  4. Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
  5. Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
  6. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  7. Private Type POINTAPI
  8. X As Long
  9. Y As Long
  10. End Type
  11. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
  12. (ByVal lpClassName As String, _
  13. ByVal lpWindowName As String) _
  14. As Long
  15. Private Declare Function ShowWindow Lib "user32" _
  16. (ByVal hwnd As Long, _
  17. ByVal nCmdShow As Long) _
  18. As Long
  19. Enum ShoeHide
  20. SH_HIDE = (0)
  21. SH_SHOW = (1)
  22. End Enum
  23.  
  24. Private Function GetHwndFromCursor() As Long
  25. Dim p As POINTAPI, K$, j$
  26. K = GetCursorPos(p)
  27. GetHwndFromCursor = WindowFromPoint(p.X, p.Y)
  28. End Function
  29. Public Function SHProg(ByVal strName As String, SH As ShoeHide)
  30. On Error Resume Next
  31. Dim lngBuf As Long
  32. lngBuf = FindWindow(vbNullString, strName)
  33. Call ShowWindow(lngBuf, SH)
  34. End Function
  35. Private Sub Timer1_Timer()
  36. Dim HwndControl As Long
  37. Dim hWndParentA As Long
  38. Dim hWndParent As Long
  39. Dim CaptionWinLen As Long
  40. Dim CaptionWin As String
  41. Dim ClassWin As String
  42. Dim ClassWinLen As Long
  43. HwndControl = GetHwndFromCursor
  44. hWndParent = HwndControl
  45. Do
  46. hWndParentA = hWndParent
  47. hWndParent = GetParent(hWndParentA)
  48. Loop Until hWndParent = 0
  49. CaptionWinLen = (GetWindowTextLength(hWndParentA)) + 1
  50. CaptionWin = String(CaptionWinLen, Chr(0))
  51. Call GetWindowText(hWndParentA, CaptionWin, CaptionWinLen)
  52. ClassWin = String$(32, Chr(0))
  53. ClassWinLen = GetClassName(hWndParentA, ClassWin, 32)
  54. ClassWin = Left(ClassWin, ClassWinLen)
  55. 'Program Manager
  56. 'NotesX
  57. If CStr("InqSoft Window Scanner") = CStr(CaptionWin) Then MsgBox ("ggggg")
  58. Text1.Text = Text1.Text + vbNewLine + CaptionWin
  59. ' Form1.Caption = CaptionWin
  60. End Sub

Решение задачи: «Ошибка с типами данных»

textual
Листинг программы
  1. Text1.SelStart = Len(Text1.Text)

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

10   голосов , оценка 4.1 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут