Sorry, that title is a bit confusing.
What I have is a program with a lot of buttons. They all do a similar thing (take a piece of text from their related fields and save it to a file), but I'm trying to streamline the code by not having to have the full write code in each button.
What I currently have is a global variable called "VSave". The idea being that in each button I define VSave as the name of that button's respective textbox and then call a function to process the text. So, each of the buttons has code like this:
... And etc.Code:Private Sub c1s_Click() VSave = "c1" Call SaveMe End Sub Private Sub c2s_Click() VSave = "c2" Call SaveMe End Sub Private Sub c3s_Click() VSave = "c3" Call SaveMe End Sub Private Sub c4s_Click() VSave = "c4" Call SaveMe End Sub Private Sub d1s_Click() VSave = "d1" Call SaveMe End Sub Private Sub d2s_Click() VSave = "d2" Call SaveMe End Sub Private Sub d3s_Click() VSave = "d3" Call SaveMe End Sub
What I'm then trying to do in the main "write" function (SaveMe) is to operate on properties of SaveMe (the contents of SaveMe is the name of the textbox, for example:
... Etc etcCode:Dim WriteString as String Dim FF As Integer FF = FreeFile() If VSave.Text = "" Then Do something End if WriteString = VSave.text
In other words, the content of VSave is the name of the textbox to be operated on, and I'm trying to perform those operations - however I cannot, as VSave itself is just a variable.
I've also tried "Val(VSave).text" but this doesn't work either.
Any ideas how I might be able to do this?
Thanks!




Reply With Quote