Saturday, 30 May 2020

VBScript: How to use Dictionary in VBScript | VBScript objects

=>To declare and create object of a vbscript dictionary:

Dim objDictionary
Set objDictionary = CreateObject("Scripting.Dictionary")


=>To add key and items into Dictionary

objDictionary.Add "1stKey", "Apple"
objDictionary.Add "2ndKey", "Ball"


=>To get count of items in dictionary

count= objDictionary.Count



=>To retrieve a item value from VBDictionary using key

msgbox objDictionary.item("1stkey")



=>To remove item use this below method

objDictionary.Remove("1stKey")


=>To remove all items or erase contents of vbDictionary

objDictionary.RemoveAll()


VBScript : How to add controls on to the HTA form and How to change a textbox value in vbscript

To add a label box and text box in to the HTA form:

<body>
    <h1>Heading</h1>
<form action="" method="">
    <p> This is a label box and text box section </p>
      <label for="UserName">UserName:</label>
     <input type="text" value="Alex" size="30" id="UserName" name="UserName">
</form>
</body>



To add a button control /submit button

<label for="ClickButton">Click on this button</label> <input type="button" id="ClickButton" name="ClickButton" value="Click Button">



How to change a textbox value in a vbscript in HTA applications:

<script language="VBScript">
          Document.getelementbyID("Textbox").innertext  = "New value of text box"
</script>

This script will update/change the textbox value to new value feeded


To add a combo box in to the HTA form:

<label for="Lblappname">Application Name</label>
<!--select value="---Select App value---">---Select App name---</option-->
<select id="testcombobox" name="testcombobox">
<option value="---Select Application name---">---Select Application name---</option>
 <script Language="VBScript">
  'FindApplicationName()
</script>

</select>


Saturday, 23 May 2020

VBScript: HTA Code to Fetch recordset values and fill to a combo box

VBScript Help: Create recordset and loop to fetch values:


         <script language="VBScript">

'======================
' Function - FetchSubscriberName
'======================
Function FetchSubscriberName
strSQL = ""
strSQL = strSQL & "SELECT distinct sub_name as sub_name                                                               FROM testsubscription
                        Set recsetApp = RunSQL(strSQL)
With recsetApp
Do While Not recsetApp.EOF
msgbox recsetApp.Fields("sub_name").Value
recsetApp.MoveNext
Loop
End with
End Function
     
</script>


VBScript Help: Create recordset and fill to a combox box


        <script language="VBScript">

'======================

' Function - FetchSubscriberName
'======================

Function FetchSubscriberName

strSQL = ""

strSQL = strSQL & "SELECT distinct sub_name as sub_name FROM                                                  testsubscription where event_name = '" & combobox2.value & "'"

                       Set recsetApp = RunSQL(strSQL)
With recsetApp

Set oDD = document.getelementbyID("Subname")

Do While Not recsetApp.EOF

Set oOpt = oDD.document.createElement("option")

oOpt.Text = recsetApp.Fields("sub_name").Value

oOpt.Value = oOpt.Text

oDD.Options.Add oOpt

'msgbox recsetApp.Fields("sub_name").Value
recsetApp.MoveNext
Loop

End with
End Function     


</script>

VBScript: How to use Dictionary in VBScript | VBScript objects

=>To declare and create object of a vbscript dictionary: Dim objDictionary Set objDictionary = CreateObject("Scripting.Dictionar...