首页 > 解决方案 > 如何使用不同类中的共享函数登录到 RichTextBox

问题描述

在执行另一个类中定义的函数时,将日志显示到 RichTextBox 的最佳方法是什么?

至于现在我已经尝试过这样的事情:

Public Class NewClass
    Public Shared Function test(ByRef rtb As RichTextBox)
        rtb.AppendText("logging")
        ''' do something useful and time consuming
        rtb.AppendText("logging")
        ''' do something useful and time consuming
        rtb.AppendText("logging")
  
    End Function
End Class

我使用NewClass.test(RichTextBox1)例如执行此功能。

它正在工作,我立即得到日志输出。

但是我在“NewClass”中有很多函数,并且希望有一种中央方式来进行日志记录,并将日志写入我的 RichTextBox。

是否有这样做的最佳实践?

非常感谢共同点!

标签: vb.netloggingrichtextbox

解决方案


推荐阅读