エディットボックスの内容の取得
Posted: 2006年2月17日(金) 08:28
EditBox1、EditBox2、EditBox3があるとして
EditBox1+EditBox2=EditBox3
のようにしたいのですがEditBoxの中身を取得する方法が分かりません
教えてください
EditBox1+EditBox2=EditBox3
のようにしたいのですがEditBoxの中身を取得する方法が分かりません
教えてください
コード: 全て選択
'EditBox1のEN_CHANGEイベント
Sub MainWnd_EditBox1_Change()
Dim strEdit1 As String
Dim strEdit2 As String
Dim strEdit3 As String
GetWindowTextStr( GetDlgItem(hMainWnd, EditBox1), strEdit1 ) 'strEdit1の内容を取得
GetWindowTextStr( GetDlgItem(hMainWnd, EditBox2), strEdit2 ) 'strEdit2の内容を取得
strEdit3 = strEdit1 + strEdit2
SetWindowText( GetDlgItem(hMainWnd, EditBox3), StrPtr(strEdit3) )'strEdit3に内容をセット
End Sub
実践コードモジュール(上記リンク先)の刹那さん さんが書きました:> "GetWindowTextStr" 無効な識別子です
コード: 全て選択
'EditBox1のEN_CHANGEイベント
Sub MainWnd_EditBox1_Change()
Dim strEdit1 As String
Dim strEdit2 As String
Dim strEdit3 As String
GetWindowTextStr( GetDlgItem(hMainWnd, EditBox1), strEdit1 ) 'strEdit1の内容を取得
GetWindowTextStr( GetDlgItem(hMainWnd, EditBox2), strEdit2 ) 'strEdit2の内容を取得
strEdit3 = strEdit1 + strEdit2
SetWindowText( GetDlgItem(hMainWnd, EditBox3), StrPtr(strEdit3) )'strEdit3に内容をセット
End Sub
'実践コードモジュールから「String型のGetWindowText」転載
Function GetWindowTextStr(hwnd As HWND, ByRef str As String) As Long
Dim Length As Long
Length = GetWindowTextLength(hwnd)
str = ZeroString(Length)
If Length = 0 Then
GetWindowTextStr = 0
Exit Function
End If
GetWindowTextStr = GetWindowText(hwnd, StrPtr(str), Length + 1)
SetDWord(StrPtr(str) - SizeOf (DWord), GetWindowTextStr)
End Function