This is a test of syntax highlighting using the excellent
Prettify JS library.
VBA Example
Public Function InCollection(col As Collection, key As String) As Boolean
Dim var As Variant
Dim errNumber As Long
InCollection = False
Set var = Nothing
Err.Clear
On Error Resume Next
var = col.Item(key)
errNumber = CLng(Err.Number)
On Error GoTo 0
'5 is not in, 0 and 438 represent incollection
If errNumber = 5 Then ' it is 5 if not in collection
InCollection = False
Else
InCollection = True
End If
End Function
Prettify and VB comments
If you need Prettify to work with VB, VBA and VB.net you'll need to make sure you include the
lang-vb.js file along with
prettify.js. You will have problems with VB comments if you don't load lang-vb (see
Prettify Issues for more detail).
<script type="text/javascript" src="/External/css/prettify/prettify.js" > </script >
<script type="text/javascript" src="/External/css/prettify/lang-vb.js" > </script >
Then add PRE block around your code eg:
<PRE class="prettyprint lang-vb">
Function SomeVB() as string
' do stuff
End Function
</PRE>
If you are experiencing problems with prettify and VB comments it's probably because you haven't loaded
lang-vb.js in addition to
prettify.js
No language specified and "nocode" example
public partial class UserControls_EMailForm : System.Web.UI.UserControl
{
private string _toemail;
public string ToEMail
{
get { return _toemail; }
set { _toemail = value; }
}
private string _smtpserver;
public string SmtpServer
{
get { return _smtpserver; }
set { _smtpserver = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
string subject = Request.QueryString["s"];
success.Visible = false;
if(!string.IsNullOrEmpty(subject)){
SubjectTextBox.Text = subject;
SubjectTextBox.Enabled = false;
}
}
... more code would go here....
}