dev*_*ull 6 ms-access vba access-vba
我们在使用Microsoft Access运行的公司中拥有旧软件(由多年前的第一批员工之一制作).老板让我在点击的特定文本框中添加随机字符串生成但我不知道如何做到这一点.我没有任何Microsoft Access编程经验,这就是为什么我要求你提供帮助.
到目前为止,我设法创建了按钮和文本字段.多数民众赞成在哪里停止.我还设法访问按钮操作的代码:
Private Sub command133_Click()
End Sub
Run Code Online (Sandbox Code Playgroud)
Bat*_*eba 11
这是一种方法,可以在Access VBA(这是一个比vb.net更旧的基础)中工作.它将生成一个包含字母和数字的字符串.
Sub test()
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
Run Code Online (Sandbox Code Playgroud)