Hi aalish,
As you're using an ASPX page on the server-side, I gather you're converting to VB.Net (different from vbscript).
I'm more familiar with C# (or JScript.Net) but I think I can help. Here are my assumptions:
1. The rst variable is previously set to open an ADODB.Recordset such that the fields "_id" and "name" are not null and do not contain HTML markup. (If it does contain valid markup, you would want to remove the call to HttpUtility.HtmlEncode() but keep the attribute encoding so as not to worry about embedded quotation marks).
2. That your original is missing an opening <span> tag, (as opposed to containing that markup).
3. That istrue and SelectedCount variables are previously defined as Integer.
4. That the typename variable is previously defined and that you can rename it. The VB IDE will auto-format this into the TypeName() function and that isn't what you want. I've used my_typename here.
I included a helper function, JsBool(), to simulate the JScript evaluation rules for a Boolean context. (Possibly "over-kill" for your actual needs). VB functions cannot be nested like JScript function so you'll want to put outside the Sub or Function block that contains your original snippet.
Best of luck,
Des
'...
While Not rst.EOF
If ((IIf(JsBool(rst.Fields("somevalue").Value), 1, 0)) <> istrue And my_typename <> rst.Fields("_id").Value) Then
Response.Write("<option value=""" & HttpUtility.HtmlAttributeEncode(rst.Fields("_id").Value) & """ style=""color: " & IIf(JsBool(rst.Fields("somevalue").Value), "red", "blue") & ";""><span>" & HttpUtility.HtmlEncode(rst.Fields("name").Value) & "</span></option>" & vbCrLf)
SelectedCount = SelectedCount + 1
End If
rst.MoveNext()
End While
'...
'End Sub/Function
Function JsBool(ByRef o As Object) As Boolean
If o Is Nothing OrElse IsDBNull(o) OrElse String.IsNullOrEmpty(o.ToString()) OrElse o.ToString() = "0" OrElse o.ToString() = "NaN" Then Return False
If IsNumeric(o) AndAlso CDbl(o) = 0 Then Return False
If TypeOf o Is Boolean AndAlso CBool(o) = False Then Return False
Return True
End Function