Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

A Q on textboxes

Posted on 1999-07-22
13
Medium Priority
?
279 Views
Last Modified: 2012-05-04
I have two text boxes, and want to paste some text from a database into the textboxes. My problem is when to know when the first textbox is full, and then I need to continue in the second, that, for that matter, have to end with a string-var '....'
They both have to update when a button is clicked ~ read in more text in and fill up as much there is space for in both textbox 1 and 2. The textboxes are set multiline=true, but there must not be any scrollbars, they are also set to -none.

Can you help?
Tahnk you!
0
Comment
Question by:CATT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
13 Comments
 
LVL 1

Accepted Solution

by:
eab111098 earned 150 total points
ID: 1526801
well if you know the length of your textbox 1 in terms of characters then its a simple matter of using clipboard.gettext().  you did mention "paste" in your question. i'm assuming then that when a user wants to move data from your database he/she is using the copy/paste functions of the database. if that is true then set some variable to clipboard.gettext(), loop thru the text one character a time until you reach the max of the first textbox and then start dumping the text into the second textbox.

ed.
0
 

Author Comment

by:CATT
ID: 1526802
well, i didn't mean paste like from the clipboard, but from the database, reading from that and 'pasting'... sending the text to the textbox, write it.
And how to fill, it must be as much as there is space for, not amount of characters.


0
 
LVL 1

Expert Comment

by:eab111098
ID: 1526803
well, if you're reading from the database then simply read it into a separate variable and then loop thru this variable and stick one character at a time into the text box until you reach the max for textbox 1 and then continue the process onto textbox 2.

ed.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:mayhew
ID: 1526804
eab,

Out of curiousity, what in the heck are
"copy/paste functions of the database"????
0
 

Author Comment

by:CATT
ID: 1526805
eab:

How am I to know when the textbox is filled??
0
 
LVL 1

Expert Comment

by:eab111098
ID: 1526806
the copy/paste/cut functions are universal in windows. simply use the ctrl-c/ctrl-p/cntrl-x to copy, paste, or cut respectively. you can do this anywhere w/in windows. copy and cut place data on the windows clipboard and paste pastes data from the clipboard.

when is a textbox filled? use the maxlength property of the textbox and set it to whatever value you want. you mentioned that you have multiline set to true and scrollbars off. well, all you need to know is how many characters can be placed in this multiline textbox and then "read" in that many before going onto your second textbox.

ed.
0
 
LVL 5

Expert Comment

by:mayhew
ID: 1526807
I'm familiar with the cut/paste functions in Windows.

I've done quite a bit of data connectivity and I've never heard of using the clipboard to get data out of a database.

How would you propose using cut and paste programmatically to get data out of an Access database, for example?
0
 
LVL 1

Expert Comment

by:eab111098
ID: 1526808
well, simply build a recordset and then use the settext method of the clipboard object. ex........

clipboard.settext recordset.fields("fieldname")

now, to get it off the clipboard you can use

text1.text = clipboard.gettext()

in your case where you want to populate a textbox with a certain number of characters and then begin filling up a second textbox, try this

i = 0
stringvariable = clipboard.gettext
do
  if len(text1.text) > text1.maxlength then
     text2.text = mid$(stringvariable,i,1)
  else
     text1.text = mid$(stringvariable,i,1)
  end if
  i = i + 1
loop until i > len(stringvariable)

is this what you're trying to do?

ed
0
 
LVL 1

Expert Comment

by:apratima
ID: 1526809
Following is the code from my project

When you are entering the code in text box (Text2(1) and Text2(2) are two text boxes) Code is as follows
In this case I fixed the text box property maxlength = 255
In database table I have created two fields of max len (ie 255 characters)

Private Sub Text2_Change(Index As Integer)
    If Index = 1 Then
        If Trim(Text2(2).Text) <> "" And Len(Text2(1).Text) < 255 Then
            MLEN = Len(Text2(1).Text)
            Text2(1).Text = Text2(1).Text + left(Text2(2).Text, (255 - MLEN))
            Text2(2).Text = Mid(Text2(2).Text, (256 - MLEN))
        End If
        If Trim(Text2(2).Text) = "" Then
            Text2(2).Enabled = False
        End If
    End If
End Sub

Private Sub Text2_GotFocus(Index As Integer)
    Focus Text2(Index)
End Sub


Private Sub Text2_KeyPress(Index As Integer, KeyAscii As Integer)
    If Index = 1 Then
        If Len(Trim(Text2(1).Text)) = 255 Then
            Text2(2).Enabled = True
            Text2(2).SetFocus
        End If
    End If
End Sub

When retrieving code from database

Text2(1).Text = IIf(IsNull(!Field1), "", !Field1)
Text2(2).Enabled = IIf(Len(Trim(!Field1)) = 255, True,False)
Text2(2).Text = IIf(IsNull(!Field2), "", !Field2)

If you have any doughts regarding code feel free to ask

0
 
LVL 5

Expert Comment

by:mayhew
ID: 1526810
Yes, I know how to use the clipboard.

Your original comment was to use the "copy/paste functions of the database".

Were you just referring to windows copy/paste?  You made it sound like there is database copy/paste functionality.

Do you get much call to use the clipboard the get data out of a database?

Why would you go to the extra step of populating the clipboard and then moving the data to a textbox?
0
 
LVL 1

Expert Comment

by:apratima
ID: 1526811
Consider the last three lines of code as written inside
With Rec   .....   End With

0
 
LVL 1

Expert Comment

by:apratima
ID: 1526812
Where is CATT? He/She is not giving any comments for the suggested solutions.
0
 

Author Comment

by:CATT
ID: 1526813
...never mind, seems I can not tell the point properly, my problem, never mind.
...

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question