VB6 DHTML - Expamples and help please!

hey yer barred

Board Regular
Joined
Jun 19, 2007
Messages
232
Hi All

I've been google-ing for well over a hour now and have found nothing to help me.

I've been using VB6 now for well over 3 years and never ever used the DHTML enviorment, and being as i have some time....im going to have a gander at it!

I have a select box that i have no idea how to add items to it from a recordset. Normally i would do this

If not(rs.eof) then
do while (not(rs.eof))
me.list1.additem = rs!Name
rs.movenext
loop
end if

This doesnt work on the html select box...can anyone help me please?

Also, can someone please post some likes to any good tutrials for this.

Your help is appresicated!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Here's a sample of an hta I use for getting WMI class information:
Code:
<head>
<title>HTA Test</title>
<HTA:APPLICATION 
     APPLICATIONNAME="HTA Test"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
Sub FillClassDropDown
   Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}root\cimv2")
   Set colClasses = objWMIService.SubClassesOf
   
   For Each objClass In colClasses
      If Left(objClass.Path_.Class,6) = "Win32_" Then
         Set objNewOption = document.createElement("OPTION")
         objNewOption.Text = objClass.Path_.Class
         WMIClasses.options.Add(objNewOption)
      End If
   Next
 
End Sub
Sub HandleClassChange
   For Each objOption In WMIClasses.Options
      If objOption.Selected = True Then
      strClass = objOption.Text
      Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}root\cimv2")
      Set objClass = objWMIService.Get(strClass)
      For Each objProperty In objClass.Properties_
          strProperties = strProperties & objProperty.Name & vbCrLf
      Next
   
      For Each objMethod In objClass.Methods_
         strMethods = strMethods & objMethod.Name & vbCrLf
      Next
      Properties.Value = strProperties
      Methods.Value    = strMethods
      End If
   Next
End Sub
Sub ShowCode
For Each objOption In WMIClasses.Options
      If objOption.Selected = True Then
     strClass = objOption.Text
  End If
Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}root\cimv2")
Set objClass = objWMIService.Get(strClass)
strCode = strCode & "Set objWMIService = GetObject(""winmgmts:"")" & vbCrLf
strCode = strCode & "Set colInstances = objWMIService.ExecQuery" & _
    "(""SELECT * FROM " & strClass & """)" & vbCrLf
strCode = strCode & "For Each objInstance In colInstances" & vbCrLf
For Each objProperty In objClass.Properties_
   strCode = strCode & "   WScript.Echo objInstance." & objProperty.Name & vbCrLf
Next
strCode = strCode & "Next" 
Code.Value = strCode
End Sub
</script>
<body onLoad=FillClassDropDown background="Lakka.jpg">
<select onChange=HandleClassChange name="WMIClasses"></select><p> 
<input onClick=ShowCode type="submit" value="Show Code"></input><p>
<textarea name="Properties" rows="5" cols="45"></textarea>
<textarea name="Methods" rows="5" cols="45"></textarea>
<textarea name="Code" rows="30" cols="93"></textarea>
</body>
</html>
if that helps. (the script tags should interest you!)
 
Upvote 0
I don't think you can. You're using VBScript rather than VB, so variables have no type and you late bind everything. You use CreateObject to instantiate new objects, rather than the New keyword.
 
Upvote 0
do you have anyidea then how i would make a ADODB connection then please?
Heres what i would normally code

Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sPath, sSQL, sconn As String

sPath = App.Path & "Test.mdb"
sconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath
db.ConnectionString = sconn
db.Open
With rs
.ActiveConnection = db
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open "SELECT * FROM tblMain"
End With

End Sub
 
Upvote 0
Code:
Dim db
Dim rs
set db = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")
... etc
Note you will have to use the literal value for constants like adLockOptimistic.
 
Upvote 0

Forum statistics

Threads
1,225,372
Messages
6,184,592
Members
453,246
Latest member
PEM000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top