Hi
I got a grid of textboxes which all need to do the same function on their doubleclick event, however the code they call needs to copy the data in the textbox to another textbox.
I don't really want to repeat the code all 32 times so am looking to create a standard sub function which can be called. That's easy enough, i am just unaware of how to make this function parse a variable depending on which textbox was clicked.
Here is what the code looks like as a private sub (sorry if it is bad coding, I haven't done this in YEARS)
Now I want to move this code into a public sub function BUT make the txtGrid1 value change depending which txtbox in the grid is double clicked.
I got a grid of textboxes which all need to do the same function on their doubleclick event, however the code they call needs to copy the data in the textbox to another textbox.
I don't really want to repeat the code all 32 times so am looking to create a standard sub function which can be called. That's easy enough, i am just unaware of how to make this function parse a variable depending on which textbox was clicked.
Here is what the code looks like as a private sub (sorry if it is bad coding, I haven't done this in YEARS)
Code:
[B]'*** check if the txtbox is null
If IsNull(txtGrid1.Value) Then
'*** Depending on which temp field has data, copy it to the txtbox
If IsNull(txtStudent1temp) Then
txtGrid1 = txtStudent2temp
txtStudent2temp = Null
Else
txtGrid1 = txtStudent1temp
txtStudent1temp.Value = Null
End If
txtGrid1.BackColor = 16777215
Else
'*** if the txtbox is not null, copy it's data to the temp field
If IsNull(txtStudent1temp) Then
txtStudent1temp = txtGrid1
txtGrid1 = Null
Else
txtStudent2temp = Null
txtStudent2temp = txtGrid1
txtGrid1 = Null
End If
txtGrid1.BackColor = 13434828
End If[/B]
Now I want to move this code into a public sub function BUT make the txtGrid1 value change depending which txtbox in the grid is double clicked.
Comment