简体   繁体   English

如何在 Access 中将 Debug.print 打印到列或文本字段中?

[英]How to Debug.print into a column or text field in Access?

Is there a way to print out results from Debug.print into a cell on a form instead of just printing in Immediate window?有没有办法将Debug.print结果打印到表单上的单元格中,而不仅仅是在立即窗口中打印? ps.附: I borrowed this code to generate passwords.我借用了这段代码来生成密码。

Private Sub Command23_Click()
Dim s As String * 8 'fixed length string with 8 characters
Dim n As Integer
Dim ch As Integer 'the character
For n = 1 To Len(s) 'don't hardcode the length twice
    Do
        ch = Rnd() * 127 'This could be more efficient.
        '48 is '0', 57 is '9', 65 is 'A', 90 is 'Z', 97 is 'a', 122 is 'z'.
    Loop While ch < 48 Or ch > 57 And ch < 65 Or ch > 90 And ch < 97 Or ch > 122
    Mid(s, n, 1) = Chr(ch) 'bit more efficient than concatenation
Next

Debug.Print s
End Sub

Add a text box to the form, and assign s as the text box's Value ...向表单中添加一个文本框,并将s指定为文本框的Value ...

Debug.Print s
Me!txtDebug.Value = s

If you want to append s to the text box Value (instead of replacing Value each time), you could add the new s value as a new line ...如果要将s附加到文本框Value (而不是每次都替换Value ),则可以将新的s值添加为新行...

Me!txtDebug.Value = Me!txtDebug.Value & vbCrLf & s

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在VBA / Access中从查询设计中调试查询结果 - How to debug.print a query result from the query design in VBA /Access 当记录存在时,MS Access VBA .recordcount返回0,而debug.print返回值 - MS Access VBA .recordcount returning 0 when records exist, and debug.print returns value VBA问题:debug.print显示正确的数据-如何从即时窗口中获取数据? - VBA question: debug.print displays the correct data - how to get it out of Immediate window? 有没有办法在使用 debug.print 时让直接窗口显示实际选项卡而不是 4 个空格 - Is there a way to make immediate window show actual tabs instead of 4 spaces when using debug.print 如何在访问查询中将访问备注字段转换为文本字段? - How to convert access memo field to text field in access query? 如何在Access Query中将数据列中的所有文本大写,同时使字段名称保持相同? - How do I capitalize all text in a column of data in an Access Query while keeping the name of the field the same? 如何在MS Access中查找字段/列源? - How to find a field/column source in MS Access? Access正在将“链接的共享点列表”文本列转换为AutoID字段 - Access is converting a Linked Sharepoint List text column into an AutoID field 如何在Access数据库文本字段中搜索子字符串 - How to search an Access database text field for a substring 访问带有备注字段作为列输出而不是文本的Make表 - Access Make table with memo field as column output instead of Text
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM