943,999 Members | Top Members by Rank

Ad:
Nov 2nd, 2009
0

=" =" "

Expand Post »
I need to copy text form a text box

for example:

My text box has

temperature="18.5"

in it and i want to copy the text 18.5 i already have it selected i just need to copy it or put it into a var
Last edited by drabsch; Nov 2nd, 2009 at 5:48 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
drabsch is offline Offline
35 posts
since Aug 2009
Nov 2nd, 2009
0
Re: =" =" "
for copy
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Clipboard.Clear
  2. Clipboard.SetText text1.SelText
for paste in other textbox
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. text2.SelText = Clipboard.GetText()
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Nov 2nd, 2009
0
Re: =" =" "
First of all, var (variance takes up unneccesary space or memory. Declare your text as an integer. i.e.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim x as Integer
  2. x = Text1.Text

The next question is? - Where do you want to copy the the temperature Integer? Into a database or just for calculation. There is different options to what you want to do...
Reputation Points: 329
Solved Threads: 347
Senior Poster
AndreRet is offline Offline
3,700 posts
since Jan 2008
Nov 3rd, 2009
0
Re: =" =" "
i found some info and i am using the code:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Function find(first, second)
  2. pos = InStr(1, Text1.Text, first, vbTextCompare)
  3. pos2 = InStr(1, Text1.Text, second, vbTextCompare)
  4. start = pos + Len(first)
  5. length = pos2 - start
  6. Text1.SelStart = start
  7. Text1.SelLength = length - 2
  8. End Function

to find and select the text.
Reputation Points: 10
Solved Threads: 0
Light Poster
drabsch is offline Offline
35 posts
since Aug 2009
Nov 3rd, 2009
0
Re: =" =" "
Now I understand. You wanted to search a text box when certain criteria is passed. You can also do the same with the following -

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explicit
  2. Private Declare Function SendMessage Lib "User32" _
  3. Alias "SendMessageA" (byval _
  4. hWnd as Long, _
  5. byval wMsg as Integer, _
  6. byval wParam as string, _
  7. lParam as Any) as Long
  8.  
  9. Const LB_FINDSTRING = &H18F
  10.  
  11. Private Sub Form_Load()
  12.  
  13. With List1
  14. .Clear
  15. .AddItem "18.5" 'or whatever you would like to add, whether from a file or database...
  16. End With
  17.  
  18. End Sub
  19.  
  20. Private Sub Text1_Change()
  21. List1.ListIndex = SendMessage(List1.hWnd, LB_FINDSTRING, _
  22. Text1, byval Text1.Text)
  23. End Sub

Note that 'Sendmessage' generates errors in Vista....
Reputation Points: 329
Solved Threads: 347
Senior Poster
AndreRet is offline Offline
3,700 posts
since Jan 2008
Nov 4th, 2009
0
Re: =" =" "
thanks
Reputation Points: 10
Solved Threads: 0
Light Poster
drabsch is offline Offline
35 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: SMS
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: POLE Display Output





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC