[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

Scrolling Marquee for Access - Causing PC to crash

Hi there,

I have written some VB code to provide a scrolling marquee for an access form.  It seems to work fine but on a couple of occasions since implementing it my PC has frozen without warning and I suspect the marquee.  Can one of the experts please check my code (adapted from previous posts on the subject), to ensure I haven't done anything wrong.

Thanks,

John
Option Compare Database
Private ScreenText As String
Private Const cStartPos = 9000
Private Const cOffset = 3000
Private stringLen As Integer
Private txtAlign As Byte
 
Private Sub Form_Open(Cancel As Integer)
    
    ScreenText = "Latest exchange rates from 'www.fxcentre.com' :  "
    ScreenText = ScreenText & "GBP>EUR " & GetRate("GBP", "EUR")
    ScreenText = ScreenText & " : "
    ScreenText = ScreenText & "DKK>EUR " & GetRate("DKK", "EUR")
    stringLen = Len(ScreenText) * 106
    If stringLen > cStartPos Then
        stringLen = cStartPos
    End If
    ResetScroll
    
End Sub
 
Private Sub cmdToggle_Click()
    If Form.TimerInterval = 0 Then
        Form.TimerInterval = 40
        Me.cmdToggle.Caption = "Stop Ticker"
    Else
        Form.TimerInterval = 0
        Me.cmdToggle.Caption = "Start Ticker"
    End If
End Sub
 
Private Sub ResetScroll()
    lblInfo.Caption = ScreenText
    lblInfo.Width = 50
    lblInfo.Left = cStartPos + cOffset - 50
    lblInfo.TextAlign = 1 'left
    txtAlign = 1
End Sub
 
Private Sub Form_Timer()
    If lblInfo.Left < 51 + cOffset And _
       lblInfo.Width < 51 Then
       ResetScroll
    End If
    If lblInfo.Left > 50 + cOffset Then
       lblInfo.Left = lblInfo.Left - 40
    End If
    If lblInfo.Width < stringLen And _
       lblInfo.TextAlign = 1 Then
       lblInfo.Width = lblInfo.Width + 40
    ElseIf lblInfo.Width >= stringLen And _
       lblInfo.TextAlign = 1 Then
       lblInfo.TextAlign = 3
    ElseIf lblInfo.Left < 51 + cOffset Then
       lblInfo.Width = lblInfo.Width - 40
    End If
End Sub

Open in new window

0
Afrofish
Asked:
Afrofish
  • 4
  • 3
1 Solution
 
Rey Obrero (Capricorn1)Commented:
try putting the codes in the Load event of the form instead of the Open event
0
 
Jeffrey CoachmanCommented:
FWIW,

I gave up on "Enhancements" like scrolling text a long time ago for reasons like this.
- Timing errors.
- Text not scrolling smoothly.
- Difficut calculating the lenght of the string against the "Appear" point and the "disappear" point.

Instead of doing this your self, you can buy a control that does this with style and professionalism. (and more options than you can dream of)
;-)
See this link:
http://www.fmsinc.com/Products/components/ControlTour/marquee.htm

JeffCoachman
0
 
AfrofishAuthor Commented:
Thanks for the help guys.

I may have found a solution (or I may have opened a whole new can of worms).  Moving the code seemed to have no effect on the problem so I decided to restart from scratch.  I thought about alternate ways of creating scrolling text and the most obvious is on websites.  The company I am creating the site for use internet explorer (which has the marquee tool built into the html).  For this reason I wrote a piece of code which created a webpage and then loaded the webpage into a microsoft (active x) web control on the page.  The only problem now is that the web control is incredibly resource hungry and the ie instance doesn't seem to shut down when the form is closed.  I think I feel another question coming on .....
Private Sub Form_Timer()
 
    createTheHTML
    webScroll.Navigate ("")
    webScroll.Navigate ("c:\marquee.html")
    cmdTicker.Caption = "Stop Ticker"
    webScroll.Visible = True
   
End Sub
 
Private Sub cmdTicker_Click()
 
If cmdTicker.Caption = "Stop Ticker" Then
    cmdTicker.Caption = "Start Ticker"
    webScroll.Navigate ("")
    webScroll.Visible = False
Else
    Form_Timer
End If
 
End Sub
 
Public Sub createTheHTML()
 
If Len(Dir("c:\marquee.html")) > 0 Then
    Kill "c:\marquee.html"
End If
Open "c:\marquee.html" For Output As #1
Print #1, "<html>"
Print #1, "<head>"
Print #1, "</head>"
Print #1, "<body bgcolor='black' marginheight='0' topmargin='0' vspace='0'"
Print #1, "marginwidth='0' leftmargin='0' hspace='0'"
Print #1, "style='margin:0; padding:0;"
Print #1, "font-family:verdana'>"
Print #1, "<font color='white'>"
Print #1, "<marquee loop='infinite'>"
Print #1, "Exchange rates from 'www.fxcentre.com' at "
Print #1, Now()
Print #1, " :  "
Print #1, "GBP>EUR " & GetRate("GBP", "EUR")
Print #1, " : SEK>EUR " & GetRate("SEK", "EUR")
Print #1, " : USD>EUR " & GetRate("USD", "EUR")
Print #1, "</marquee>"
Print #1, "</font>"
Print #1, "</body>"
Print #1, "</html>"
Close #1
 
End Sub

Open in new window

0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Jeffrey CoachmanCommented:
Anything that requires continuous timer hits will put a drain on your resources.

Is this scrolling a required feature?

Again, the control I mentioned from FMSinc is a lot less resource hungry.
0
 
AfrofishAuthor Commented:
Thats why I thought the website would work, It doesn't use any timer hits (atleast not in access) and I have seen scrolling text on pre-pentium PCs so it should be a breeze for modern computers.  
0
 
AfrofishAuthor Commented:
Sorry boag2000, I didn't answer your question fully.  The control is not mission critical but my employer is very keen to get it working and I am trying to avoid disappointing him.  As to the FMS control, I am sure it will do a great job but I don't want to add any further costs to the database (as it would be me who would have to pay for them).
0
 
Jeffrey CoachmanCommented:
OK
0
 
AfrofishAuthor Commented:
Ok Guys,

Thankyou for all the help you gave me on this matter.  I am not sure if the finished article is a solution or a work-around but it seems to have stopped the problems and that's the main thing.  I have basically moved the code which downloads the rates to a processing database which is used to update stock data from the production facility.  After obtaining the rates the processor creates a html file on the server which I then read into the database as and when required.  As mentionned above the scrolling is achieved using the marquee functionality in ie which shouldn't be a problem as ie is part of the standard desktop for the company in question.  The code is essentially the same as above.

Thanks Again,

John
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now