问题:Excel中Textbox控件以及Form里的Textbox控件,当直接填充的内容很长时,滚动条不能实时刷新。

现象:

修改后:

原因:

虽然已经向Textbox的Text里设置了内容,但此时Textbox并没有被激活,焦点也没有变化,所以,Textbox的滚动条没有被刷新出来。

修改后的VBA程序:

-----------------------ActiveX Textbox--------------------------

Private Sub CommandButton1_Click()

    TextBox1.Value = "safdasfgsdfgfhfgjhfjfghjfhjfg" _
& Chr() _
& "" _
& Chr() ' IF the text length is long enough, ENABLE the Textbox's scroll bar
TextBox1.Activate
' Set the current select line: 0
TextBox1.CurLine = End Sub

-----------------------Form Textbox--------------------------

Private Sub CommandButton1_Click()

    TextBox1.Value = "safdasfgsdfgfhfgjhfjfghjfhjfg" _
& Chr() _
& "" _
& Chr() ' IF the text length is long enough, ENABLE the Textbox's scroll bar
TextBox1.SetFocus
' Set the current select line: 0
TextBox1.SelStart = End Sub

知识点:

ActiveX Textbox中的 TextBox1.Activate 和 Form Textbox的 TextBox1.SetFocus功能相同

最新文章

  1. nginx设置不使用缓存 add_header Cache-Control no-cache
  2. 【转】Java HashMap 源码解析(好文章)
  3. Django中如何使用django-celery完成异步任务1(转)
  4. 【Linux C中文函数手册】之 目录操作函数
  5. LeetCode Letter Combinations of a Phone Number 电话号码组合
  6. PHP获取函数返回值的引用
  7. expected function body after function declarator
  8. XML IList<T> TO DataSet TO DataTable 相互转换
  9. OPENCV基本滤波算法
  10. 线上Django项目python2到3升级日记
  11. java游戏开发杂谈 - java是什么
  12. vue打包速度优化
  13. PyCon大会Python主题演讲摘要
  14. linux下面发布80端口的服务
  15. 2018-2019-20172329 《Java软件结构与数据结构》第三周学习总结
  16. 转载-好用的linux软件合集
  17. Android 面试收集录5 消息机制
  18. EAR、JAR、WAR(IT)
  19. scikit-learn(project中用的相对较多的模型介绍):1.14. Semi-Supervised
  20. 我在B站学习 清华大学教授带你学习c++(进阶)构造函数

热门文章

  1. BZOJ 2115: [Wc2011] Xor [高斯消元XOR 线性基 图]
  2. controller 单元测试
  3. Django搭建博客网站(四)
  4. Redis 实践1- redis介绍和安装
  5. Python报错:IndentationError: expected an indented block
  6. ch11 持有对象
  7. Egret学习笔记.1 (写在前面的废话)
  8. ubuntu网络设置及遇到问题
  9. C# 枚举特性 FlagAttribute 的应用
  10. 笔记︱图像语义分割(FCN、CRF、MRF)、论文延伸(Pixel Objectness、)