+ Reply to Thread
Results 1 to 7 of 7

Real-Time TextBox Data Entry

Hybrid View

  1. #1
    Registered User
    Join Date
    12-06-2013
    Location
    Prescott, AZ
    MS-Off Ver
    Excel 2010
    Posts
    4

    Real-Time TextBox Data Entry

    Hello Folks,

    First time poster...

    I am running Excel 2010 VBA to control various pieces of Agilent test equipment via a National Instruments USB to GPIB interface. During code execution I am collecting data from the test equipment and attempting to display the data in various ActiveX TextBox's (No UserForms). My issue is that the Text data only appears in the Textbox upon completion of code execution (The last data element collected is displayed). How do I get my Text data to appear in the TextBox real-time or during code execution? ( I can write to an Excel "cell" real-time without issue).

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Real-Time TextBox Data Entry

    Try the DoEvents function after you've updated the textbox value.

  3. #3
    Registered User
    Join Date
    12-06-2013
    Location
    Prescott, AZ
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Real-Time TextBox Data Entry

    natefarm,

    Thanks for the suggestion.

    Unfortunately it did not work.

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Real-Time TextBox Data Entry

    Hmm. This is the coded I tried when testing it out. Without the DoEvents function, it updated all three textboxes at the end. When I added DoEvents, it updated Textbox1 immediately.
    Sub Test()
    Dim i As Long
    
        ActiveSheet.OLEObjects("TextBox1").Object.Value = "test1"
    
        DoEvents
        Do Until i = 1000
            Cells(1, 1).Value = "test"
            i = i + 1
        Loop
    
        ActiveSheet.OLEObjects("TextBox2").Object.Value = "test2"
        ActiveSheet.OLEObjects("TextBox3").Object.Value = "test3"
    End Sub

  5. #5
    Registered User
    Join Date
    12-06-2013
    Location
    Prescott, AZ
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Real-Time TextBox Data Entry

    That's interesting...

    When I run your code the results are the same with or without the DoEvents function. All the TextBox's get updated at the end of program execution.

    What am I missing?

  6. #6
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Real-Time TextBox Data Entry

    Well, I'm sorry. Now it's not working for me either. However, I did try the following and it seemed to work.
    Don't jinx it!
    Sub Test()
    Dim i As Long
    
        ActiveSheet.OLEObjects("TextBox1").Object.Value = "test1"
    
        Application.ScreenUpdating = False
        Application.ScreenUpdating = True
        Do Until i = 10000
            Cells(1, 1).Value = "test"
            i = i + 1
        Loop
    
        ActiveSheet.OLEObjects("TextBox2").Object.Value = "test2"
    End Sub

  7. #7
    Registered User
    Join Date
    12-06-2013
    Location
    Prescott, AZ
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Real-Time TextBox Data Entry

    Upon further review...

    It seems the DoEvents Function has a positive impact on my issue. The TextBox does not update upon execution of the DoEvents Function, but it seems as though the TextBox updates when the "Loop" syntax is executed as part of a "Do" loop. Its hard to say exactly when the TextBox is updated during program execution, simply because whenever I "Run to Cursor" the TextBox gets updated at the trapping point regardless. Without the DoEvents function the TextBox only updates at program completion.

    The TextBox update behavior is now satisfactory for my purposes.

    The Application.ScreenUpdating was not effectual at all. Go figure...

    Thanks for your help natefarm!

    I hope you have a safe and happy Holiday season.

    Pier722

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] UserForm SpinButton to increment Time after TextBox Entry
    By GRazor71 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-02-2013, 01:10 PM
  2. How to create a read-only "real-time" textbox
    By skysurfer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-19-2010, 05:05 PM
  3. Real-Time Data
    By bobajob in forum Excel General
    Replies: 3
    Last Post: 11-01-2007, 03:00 PM
  4. [SOLVED] [SOLVED] VBA with real time data
    By jain.pb@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2006, 04:45 PM
  5. [SOLVED] data entry to next blank TextBox
    By csellens22@msn.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2005, 06:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1