Poop Holy
asked on
Anyone can help me perfect this function?
Anyone can help me perfect the Me.txt&Ibox&J = &I “v” &J
Dim I, J As Integer
For I = 1 To 2
For J = 1 To 5
Me.txt&Ibox&J = &I “v” &J
Next J
Next I
Example : Me.txt1box1 = 1v1
Example : Me.txt1box3 = 1v3
Example : Me.txt2box1 = 2v1
Example : Me.txt2box5 = 2v5
At the unbound box txt1box1, it will show 1v1 as output
Dim I, J As Integer
For I = 1 To 2
For J = 1 To 5
Me.txt&Ibox&J = &I “v” &J
Next J
Next I
Example : Me.txt1box1 = 1v1
Example : Me.txt1box3 = 1v3
Example : Me.txt2box1 = 2v1
Example : Me.txt2box5 = 2v5
At the unbound box txt1box1, it will show 1v1 as output
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just as a side comment, two things:
1. You'll find your code easier to maintain in the future if you start giving your variables meaningful names. ie.
It also helps if you prefix the variable with the type (int = Integer, lng = Long, var = variant, etc). There are several naming conventions out there. It's not important which one you use, just that you use one and use it consistently.
2. The other thing you should do is include comments that explain what your are doing. Example:
' Set the text in the row and column controls
' to display ......
You do not want to say what the code is doing, but rather why you are doing it. For example, when deleting a file, this:
' Delete the file
Kill strFile
does not tell me much. It is obvious from the Kill statement that I am deleting a file. This is far better:
' Remove the temp work file before creating a new one.
' If we don't, this will cause an error
Kill strFile
Doing this will help you considerably in the future when you go to make changes in the code.
Jim.
1. You'll find your code easier to maintain in the future if you start giving your variables meaningful names. ie.
Dim intRow as integer, intCol As Integer
For intRow = 1 To 2
For intCol= 1 To 5
Me("txt" & intRow & "box" & intCol) = intRow & “v” & intCol
Next intCol
Next intRow
It also helps if you prefix the variable with the type (int = Integer, lng = Long, var = variant, etc). There are several naming conventions out there. It's not important which one you use, just that you use one and use it consistently.
2. The other thing you should do is include comments that explain what your are doing. Example:
' Set the text in the row and column controls
' to display ......
You do not want to say what the code is doing, but rather why you are doing it. For example, when deleting a file, this:
' Delete the file
Kill strFile
does not tell me much. It is obvious from the Kill statement that I am deleting a file. This is far better:
' Remove the temp work file before creating a new one.
' If we don't, this will cause an error
Kill strFile
Doing this will help you considerably in the future when you go to make changes in the code.
Jim.
You might want to take the time to view this:
https://www.experts-exchange.com/videos/536/MS-Access-Writing-Solid-VBA-Code.html
It's short (less than 5 minutes).
Jim.
https://www.experts-exchange.com/videos/536/MS-Access-Writing-Solid-VBA-Code.html
It's short (less than 5 minutes).
Jim.
ASKER