-
Mar 2nd, 2009, 03:40 AM
#1
Thread Starter
New Member
[RESOLVED] Help! I can not copy the content of Text1.Text
Dear experts,
I got the souce code below from the the forum & it work for me but I can not copy the content/outcome of Text1.Text I want....or canthe code produce the content/outcome of Text1.Text to text1.txt?
Appreciate your help...Thank You
Option Explicit
Const LB_FINDSTRING = &H18F
Const LB_FINDSTRINGEXACT = &H1A2
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Dim wow() As String
Private Sub Command1_Click()
AddToListBox Text1.Text
End Sub
Private Sub Command2_Click()
Dim i As Integer
wow() = Split(Text1.Text, vbCrLf)
For i = LBound(wow) To UBound(wow)
AddToListBox wow(i)
Next i
End Sub
Public Sub AddToListBox(AddMe As String)
Dim wow As Long
wow = SendMessage(List1.hWnd, LB_FINDSTRINGEXACT, 0, ByVal AddMe)
If wow = -1 Then
List1.AddItem AddMe
Else
List1.ListIndex = wow
Debug.Print List1.Text
End If
End Sub
-
Mar 2nd, 2009, 03:47 AM
#2
Re: Help! I can not copy the content of Text1.Text
No need to use API to export text from textbox. use this simle code...
vb Code:
Dim outputstring as string
outputstring = Text1.Text
Open "C:/MyTextFile.txt" For Output As #1
Print #1, outputstring
Close #1
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Mar 2nd, 2009, 03:58 AM
#3
Frenzied Member
Re: Help! I can not copy the content of Text1.Text
pls ensure to INDENT the codes and post them with CODE tags
Code:
Option Explicit
Const LB_FINDSTRING = &H18F
Const LB_FINDSTRINGEXACT = &H1A2
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Dim wow() As String
Private Sub Command1_Click()
AddToListBox Text1.Text
End Sub
Private Sub Command2_Click()
Dim i As Integer
wow() = Split(Text1.Text, vbCrLf)
For i = LBound(wow) To UBound(wow)
AddToListBox wow(i)
Next i
End Sub
Public Sub AddToListBox(AddMe As String)
Dim wow As Long
wow = SendMessage(List1.hWnd, LB_FINDSTRINGEXACT, 0, ByVal AddMe)
If wow = -1 Then
List1.AddItem AddMe
Else
List1.ListIndex = wow
Debug.Print List1.Text
End If
End Sub
what's not working.
what are you trying to do?
-
Mar 2nd, 2009, 04:17 AM
#4
Thread Starter
New Member
Re: Help! I can not copy the content of Text1.Text
Originally Posted by koolsid
No need to use API to export text from textbox. use this simle code...
vb Code:
Dim outputstring as string
outputstring = Text1.Text
Open "C:/MyTextFile.txt" For Output As #1
Print #1, outputstring
Close #1
thank you koolsid, it work
but I think I have posted the wrong output file
what I need in fact is the output List1 file not the text1.tex
can u guide me ? Thank You!
-
Mar 2nd, 2009, 04:21 AM
#5
Thread Starter
New Member
Re: Help! I can not copy the content of Text1.Text
Originally Posted by VBFnewcomer
pls ensure to INDENT the codes and post them with CODE tags
Code:
Option Explicit
Const LB_FINDSTRING = &H18F
Const LB_FINDSTRINGEXACT = &H1A2
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Dim wow() As String
Private Sub Command1_Click()
AddToListBox Text1.Text
End Sub
Private Sub Command2_Click()
Dim i As Integer
wow() = Split(Text1.Text, vbCrLf)
For i = LBound(wow) To UBound(wow)
AddToListBox wow(i)
Next i
End Sub
Public Sub AddToListBox(AddMe As String)
Dim wow As Long
wow = SendMessage(List1.hWnd, LB_FINDSTRINGEXACT, 0, ByVal AddMe)
If wow = -1 Then
List1.AddItem AddMe
Else
List1.ListIndex = wow
Debug.Print List1.Text
End If
End Sub
what's not working.
what are you trying to do?
Dear, VBFnewcomer,
Can u help?
Code:
Option Explicit
Const LB_FINDSTRING = &H18F
Const LB_FINDSTRINGEXACT = &H1A2
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Dim wow() As String
Private Sub Command1_Click()
AddToListBox Text1.Text
End Sub
Private Sub Command2_Click()
Dim i As Integer
wow() = Split(Text1.Text, vbCrLf)
For i = LBound(wow) To UBound(wow)
AddToListBox wow(i)
Next i
End Sub
Public Sub AddToListBox(AddMe As String)
Dim wow As Long
wow = SendMessage(List1.hWnd, LB_FINDSTRINGEXACT, 0, ByVal AddMe)
If wow = -1 Then
List1.AddItem AddMe
Else
List1.ListIndex = wow
Debug.Print List1.Text
End If
Dim outputstring As String
outputstring = List1.Text
Open "C:/MyTextFile.txt" For Output As #1
Print #1, outputstring
Close #1
End Sub
I need the output txt file in the List1 Listbox but the above code can not work
-
Mar 2nd, 2009, 05:39 AM
#6
Thread Starter
New Member
Re: Help! I can not copy the content of Text1.Text
finally, it works....thank you!
Code:
Option Explicit
Const LB_FINDSTRING = &H18F
Const LB_FINDSTRINGEXACT = &H1A2
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Dim wow() As String
Private Sub Command1_Click()
AddToListBox Text1.Text
End Sub
Private Sub Command2_Click()
Dim i As Integer
wow() = Split(Text1.Text, vbCrLf)
For i = LBound(wow) To UBound(wow)
AddToListBox wow(i)
Next i
End Sub
Public Sub AddToListBox(AddMe As String)
Dim wow As Long
wow = SendMessage(List1.hWnd, LB_FINDSTRINGEXACT, 0, ByVal AddMe)
If wow = -1 Then
List1.AddItem AddMe
Else
List1.ListIndex = wow
Debug.Print List1.Text
End If
End Sub
Private Sub Command3_Click()
Dim N As Integer
Open "C:\List.txt" For Output As #1
For N = 0 To List1.ListCount - 1
Print #1, List1.List(N)
Next
Close #1
End Sub
-
Mar 2nd, 2009, 05:47 AM
#7
Frenzied Member
Re: [RESOLVED] Help! I can not copy the content of Text1.Text
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|