Jump to content

Concatenate commands

Guest henkvisser

Recommended Posts

Guest henkvisser

Hi. I'm not sure if it is possible but here's the code I want to use;

Sub CheckBoxVisibility(sControlName)	Dim checkbox, editbox, picklist	checkbox = "chk" & sControlName & ".state"	editbox = "edb" & sControlName & ".Visible"	picklist = "pkl" & sControlName & ".Visible"	  if checkbox = cbChecked then		 editbox = True		 picklist = False	  elseif checkbox = cbUnchecked then		 editbox = False		 picklist = True	  end ifend subSub chkSM1Click(Sender)	Dim sControlName	sControlName = Right(Sender.name, 3)	Call CheckboxVisibility(sControlName)End Sub

In short, I have controls like edbSM1 (editbox), edbSM2, edbSM3, chkSM1 (checkbox), chkSM1, pklSM1 (picklist), pklSM2. It would save time to use a functions as above to use dynamic controls. But it doesn't recognize

checkbox = "chk" & sControlName & ".state"

as a control and its attribute, so the if doesn't work and always returns false. It should return


which is obviously the state of the checkbox. So is it possible to concatenate controls/commands???

Link to post
Share on other sites

It has been a long time since I worked regularly with VBScript, but don't you have to use the DOM to get at an element in the HTML?If you ran

checkbox = "chk" & sControlName & ".state"

checkbox should just contain a string ("chkSM2.state" for example);In javascript, you'd have to use something like this:

var checkbox = document.getElementById("chk" + sControlName);var state = checkbox.state;

EDIT: If you can access the state of a checkbox by using chkSM1.state, then you might try something like this:

checkbox = "chk" & sControlNamestate = checkbox.state

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...