473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How can a text box be scrolled in the screen

Hai Friends,
I am in the process of designing a project. On the startup screen I want a text box or a label scroll in the screen. I need help in writting code for the above.
==rajendran r
Jan 20 '13 #1

✓ answered by TheSmileyCoder

I am usually the one preaching that there is nothing that can not be done in Access if you have a little Zezt, spirit and free thinking. I really should not have given up so quickly. Inspired by ADezii I tried to go another path. I have uploaded the result as a video:
http://www.youtube.com/watch?v=aPWcI533nbs
and the sample db is also attached
Attachment 6853
(Saved in 2003 format, though I am unsure if the left margin property was available in 2003, so db might not open. Give it a test someone with 2003)

Just like ADezii, I made a form with a unbound textbox as wide as the form (Though it doesn't have to be). Set the timer to 100 and this code in the timer event+declaration:
Expand|Select|Wrap|Line Numbers
  1. Private Const m_strDisplayText As String = "TheSmileyCoders scrolling text"
  2.  
  3. Private Sub Form_Timer()
  4. Static bInit As Boolean
  5.  
  6.    If Not bInit Then
  7.       Static t As TextBox
  8.       Set t = Me.tb_Scroller
  9.       t.Value = m_strDisplayText
  10.       'Set internal leftmargin to match width
  11.       t.LeftMargin = t.Width - 1
  12.       bInit = True
  13.    End If
  14.  
  15. 'Lngstep is how much the margin should move per iteration
  16.    Dim lngStep As Long
  17.    lngStep = 150 'Note for a smooth appearance, match this roughly to the size of a char
  18.  
  19.    'Move leftmargin until you run out of space
  20.    If t.LeftMargin - lngStep >= 1 Then
  21.       t.LeftMargin = t.LeftMargin - lngStep
  22.    Else
  23.       'Once you run out of space, eat charecters instead
  24.       If Len(t.Value) > 1 Then
  25.          t.Value = Mid(t.Value, 2)
  26.       Else
  27.          'Once you run out of charecters restart
  28.          bInit = False
  29.       End If
  30.    End If
  31. End Sub

P.S. Thanks ADezii for the inspirational nudge.

12 12856
TheSmileyCoder
2,322 Expert Mod 2GB
Place a textbox onto your form, then look at its properties. Set its ScrollBar property to Both, or Vertical.

Note that memo fields dragged onto a form automatically gets this property set (atleast in 2010)
Jan 20 '13 #2
Sir, Thanks in prompt guiding. But I have asked about the text box / label scrolling from left to right on the screen. Kindly do help
Jan 20 '13 #3
TheSmileyCoder
2,322 Expert Mod 2GB
I don't know of any easy way of doing this. A limited form could be a timer driven event where you move the left property of a textbox, but that would only work inside the form I believe.

If you want something more fancy (and smooth) you will need to look into API calls I think. Can't help you there.
Jan 20 '13 #4
NeoPa
32,556 Expert Mod 16PB
The only scrollbar available on a TextBox control is the Vertical one. Labels have none. As Smiley says, you'll need to do something outside of the box like designing your own specific control. Possible, but very advanced, and not done in VBA I believe (so we'd be unable to help in this forum generally).
Jan 20 '13 #5
ADezii
8,834 Expert 8TB
If you are looking for something similar to a 'Scrolling Marquee', you can accomplish this very simply.
  1. Create a Text Box/Label on your Form and set its Width to that of the Form's.
  2. Display no Text in the Text Box.
  3. Set the Text Align Property of your Text Box to Center.
  4. Set the Timer Interval of the Form to 1000 (1 second). This can be changed to adjust the 'Scrolling' display of the Characters.
  5. Copy-N-Paste the following Code into the Timer() Event of the Form.
  6. Open the Form.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Timer()
    2. 'Replace with your Scrolling Text
    3. Const conTEXT_TO_SCROLL As String = "Scrolling Text Demo"
    4. Static intCharCtr As Integer
    5.  
    6. intCharCtr = intCharCtr + 1
    7.  
    8. If intCharCtr > Len(conTEXT_TO_SCROLL) Then intCharCtr = 1
    9.  
    10. Me![Text2] = Mid$(conTEXT_TO_SCROLL, 1, intCharCtr)
    11. End Sub
    12.  
  7. Your String will display Character by Character until the last Character, at which time the process will start over again.
Jan 20 '13 #6
TheSmileyCoder
2,322 Expert Mod 2GB
I am usually the one preaching that there is nothing that can not be done in Access if you have a little Zezt, spirit and free thinking. I really should not have given up so quickly. Inspired by ADezii I tried to go another path. I have uploaded the result as a video:
http://www.youtube.com/watch?v=aPWcI533nbs
and the sample db is also attached
ScrollingSplash.zip
(Saved in 2003 format, though I am unsure if the left margin property was available in 2003, so db might not open. Give it a test someone with 2003)

Just like ADezii, I made a form with a unbound textbox as wide as the form (Though it doesn't have to be). Set the timer to 100 and this code in the timer event+declaration:
Expand|Select|Wrap|Line Numbers
  1. Private Const m_strDisplayText As String = "TheSmileyCoders scrolling text"
  2.  
  3. Private Sub Form_Timer()
  4. Static bInit As Boolean
  5.  
  6.    If Not bInit Then
  7.       Static t As TextBox
  8.       Set t = Me.tb_Scroller
  9.       t.Value = m_strDisplayText
  10.       'Set internal leftmargin to match width
  11.       t.LeftMargin = t.Width - 1
  12.       bInit = True
  13.    End If
  14.  
  15. 'Lngstep is how much the margin should move per iteration
  16.    Dim lngStep As Long
  17.    lngStep = 150 'Note for a smooth appearance, match this roughly to the size of a char
  18.  
  19.    'Move leftmargin until you run out of space
  20.    If t.LeftMargin - lngStep >= 1 Then
  21.       t.LeftMargin = t.LeftMargin - lngStep
  22.    Else
  23.       'Once you run out of space, eat charecters instead
  24.       If Len(t.Value) > 1 Then
  25.          t.Value = Mid(t.Value, 2)
  26.       Else
  27.          'Once you run out of charecters restart
  28.          bInit = False
  29.       End If
  30.    End If
  31. End Sub

P.S. Thanks ADezii for the inspirational nudge.
Jan 20 '13 #7
ADezii
8,834 Expert 8TB
@TheSmileyCoder
No problem as far as the inspirational nudge, TheSmileyCoder. I just tried to get the most effect out of the least amount of Code (LOL).
Jan 20 '13 #8
NeoPa
32,556 Expert Mod 16PB
Are we talking about a control where the contents are manually scrollable (as in with a scroll-bar) or a control with automatically scrolling contents? I was thinking of the former, but if the question (which I didn't find very clear, so my interpretation may well be wrong) is about the latter then clearly there is more scope. It must be hard expressing a technical question in another language, so I'm not criticising the OP for their lack of clarity.
Jan 21 '13 #9
Thank you for handy help. Even though this has not purport the requirement, your animation works smoothly. Lot of thanks.

I have opened yr file. But i have received an error message that the database or project contains a missing or broken reference to the file "acedao.dll" version 12.0
how can i overcome this?
Jan 27 '13 #10
TheSmileyCoder
2,322 Expert Mod 2GB
That would be a missing reference due to me using a newer version of access. You should be able to remove the broken reference and replace it with a newer one.

Try the following:
Open the access file
Hit Alt-F11 to open the VB editor.
Go Tools->References
You should now see a dialog box with a list of references.



I believe it is likely its the one highlight in blue that will have be missing/broken. Uncheck the reference, and find the one relevant to the version of access you are using. (There will only be one, unless you have multiple versions installed)
Attached Images
File Type: jpg ReferenceDialog.jpg (73.0 KB, 6189 views)
Jan 27 '13 #11
Sir, Thanks. I am using Access 2003 version. I could not locate the file named in your reply in the reference. However, I propose to load Access 2007 version in my system and try your code. Thank you.
Jan 28 '13 #12
TheSmileyCoder
2,322 Expert Mod 2GB
As I said:
TheSmileyCoder
Uncheck the reference, and find the one relevant to the version of access you are using.
Best of luck with your project.
Jan 28 '13 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paolo Bonzini | last post by:
I have a page (http://www.polimi.it) with a news ticker on it. I want to have all the ticker's news read by a screen reader, which is easy enough using the off-left trick, but also to have to...
7
by: Paul Gorodyansky | last post by:
Hi, Say I have a text in my TEXTAREA box - 01234567890 I want - using script - insert say "abc" in the middle. Works almost OK in Internet Explorer (with one problem) based on their example...
3
by: Seifer | last post by:
Hi. how can i grab text (a word or a line) from any windows (and any controls) where the mouse is pointing??? Help me. Thanks.
2
by: Jake Barnes | last post by:
In the function below I use a call to Prototype to get some text from another webpage and I fill a div with it. You can see the red, narrow div halfway down this page: ...
8
by: gtpilot | last post by:
I have a program that is going to return position data several times a second. Instead of printing this data to the screen on new line every time, I would like to simply have the program print...
2
by: Rick | last post by:
Let me start by saying that I know very little about JavaScript. The software that I use to convert my FrameMaker files to HTML uses a JavaScript to hide certain text. The user has to click the...
12
by: Boris Borcic | last post by:
Hello, I am trying to use UI Automation to drive an MS Windows app (with pywinauto). I need to scrape the app's window contents and use some form of OCR to get at the texts (pywinauto can't...
5
Mohan Krishna
by: Mohan Krishna | last post by:
Hi everyone! Can we get the text scrolled on the title bar of the VB Project Form? The text may be the name of the company to which I am developing the project. Please give me answer asap! ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.