Normalize Field Name

This snippet will take a variable and translate it to how it would appear as an IDEA field name.

Snippet: 

Field names in IDEA need to be uppercase and not contain any special characters. This snippet will first take a field name and change it to upper character and then check and change any non alpha numeric characters to an underscore.  It could be used if you are asking a user for a field name that you will be creating, so that the variable will hold the same as what IDEA will show you would use this funciton as IDEA will automatically make changes to the field name and if you don't do the same you may have errors in your script.

Function normalizeFieldName(sTempFieldName As String) As String
	Dim iLen As Integer
	Dim i As Integer
	Dim sChar As String
	Dim sNewFieldName As String
	
	sTempFieldName = UCase(sTempFieldName)
	iLen = Len(sTempFieldName)
	
	For i = 1 To iLen
		sChar = Mid(sTempFieldName, i, 1)
		If (Asc(sChar) < 48 Or Asc(sChar) > 57) And (Asc(sChar) < 65 Or Asc(sChar) > 90) Then
			sNewFieldName = sNewFieldName & "_"
		Else 
			sNewFieldName = sNewFieldName & sChar 
		End If  	
	Next i
	
	normalizeFieldName = sNewFieldName
End Function