troubleshooting Question

sorting with vbscript

Avatar of tarashea
tarashea asked on
VB Script
9 Comments1 Solution878 ViewsLast Modified:
I am working on a project that has some existing scripts written for it.  i am not familiar with vbscript.  currently this file displays in a chart by the parent hybrid.  I need the chart to sort by parent hybrid, and within each hybrid family, sort by relative maturity.   the only products that have relative maturity are grain corn, silage corn, and sorghum.  i have attached the file.  any input on how to sort within a pre-existing sort would be much appreciated.  I believe the sort takes place in the Function GetFmtTables.
Dim strScope
strScope = "_gl"
 
'Start of Sort functions
const CMP_LESS = -1
const CMP_EQU = 0
const CMP_GREATER = 1
 
const ORDER_ASC = 1
const ORDER_DESC = -1
 
function qsort_cmp(a,b)
	if a < b then 
		qsort_cmp = CMP_LESS
	elseif a > b then 
		qsort_cmp = CMP_GREATER
	else 
		qsort_cmp = CMP_EQU
	end if
end function
 
function array_swap(values, i,j)
	dim temp: temp = values(i)
	values(i) = values (j)
	values(j) = temp
end function
 
function array_swapO(values, i,j)
	dim temp : set temp = values(i)
	set values(i) = values (j)
	set values(j) = temp
end function
 
class QSort
	private f_order
	private f_cmp
	private f_swap
	private valueSort
	
	private sub class_initialize
		f_order = ORDER_ASC
	end sub
 
	' Compare a and b, taking the sort-order into account
	' If DESC, reverse the results of the comparison	
	private function comp(a,b)
		comp = f_cmp(a,b) * f_order
	end function
	
	private sub QSort(values, loBound,hiBound)
		dim pivot,loSwap,hiSwap
	
	  '== Two items to sort
		if hiBound - loBound = 1 then
			if comp(values(loBound), values(hiBound)) = CMP_GREATER then
				f_swap values,loBound,hiBound
			end if
			exit sub
		end If
	
	  '== Three or more items to sort
		dim pivotIndex : pivotIndex = int((loBound + hiBound) / 2)
		
		if valueSort then
			pivot = values(pivotIndex)
		else
			set pivot = values(pivotIndex)
		end if
		
		f_swap values, pivotIndex, loBound
		
		loSwap = loBound + 1
		hiSwap = hiBound
	  
		do
			'== Find the right loSwap
			while (loSwap < hiSwap) and (comp(values(loSwap), pivot) <> CMP_GREATER)
				loSwap = loSwap + 1
			wend
			'== Find the right hiSwap
			while (comp(values(hiSwap), pivot) = CMP_GREATER)
				hiSwap = hiSwap - 1
			wend
			'== Swap values if loSwap is less then hiSwap
			if loSwap < hiSwap then
				f_swap values, loSwap, hiSwap
			End If
		loop while loSwap < hiSwap
	  
		if valueSort then
			values(loBound) = values(hiSwap)
			values(hiSwap) = pivot
		else
			set values(loBound) = values(hiSwap)
			set values(hiSwap) = pivot
		end if
	  
		'== Recursively call function
		'== 2 or more items in first section
		if loBound < (hiSwap - 1) then QSort values, loBound,hiSwap-1
		'== 2 or more items in second section
		if hiSwap + 1 < hibound then QSort values, hiSwap+1,hiBound
	End Sub
 
	public property set Compare(func)
		set f_cmp = func
	end property
	
	public property let Order(sortOrder)
		set f_order = sortOrder
	end property
	
	public sub Sort(values)
		' Don't sort empty arrays or arrays with only 1 value
		if UBound(values) < 1 then exit sub
		valueSort = false
		
		if IsEmpty(f_cmp) then
			valueSort = true
			set f_cmp = GetRef("qsort_cmp")
			set f_swap = GetRef("array_swap")
		else
			set f_swap = GetRef("array_swapO")
		end if
		
		QSort values, LBound(values), UBound(values)
 
		if valueSort then f_cmp = Empty
	end sub
end class
 
'Main Code
class Thing
	public val
end class
 
function make_thing(value)
	dim t : set t = new Thing
	t.val = value
	set make_thing = t
end function
 
function cmp_thing(a, b)
	Dim ca, cb
	ca = CLng(Split(a.val, ":")(0))
	cb = CLng(Split(b.val, ":")(0))
	
	if (ca < cb) then
		cmp_thing = CMP_LESS
	elseif (ca > cb) then
		cmp_thing = CMP_GREATER
	else
		cmp_thing = CMP_EQUAL
	end if
end function
'End of Sort functions
 
'Function to return Special Traits of Crops in SHORT
function getSpecialTraits (stHID, strColumnName, strSelect)
 
	Dim lglTraits, strSQLQuery
 
	Dim strHybridID
	strHybridID = stHID
	
	'Safety Catch - Reset Hybrid ID to PRIME_KEY if not passed
	if IsEmpty(strHybridID) then
		strHybridID = PfGetValue("PRIME_KEY")
	end If
 
	Dim strEmpty
	strEmpty = ""
 
	'Has to RETURN if empty HybridID
	if IsEmpty(strHybridID) then
		getSpecialTraits = strEmpty
		Exit Function
	end If
 
	'Has to RETURN if empty Base Column
	if IsEmpty(strColumnName) then
		getSpecialTraits = strEmpty
		Exit Function
	end If
 
	Dim Cnxn
	' Create and open SQL Connection
	Set Cnxn = CreateObject("ADODB.Connection") 
	Cnxn.Open  strCnxnTbl
 
	Dim Cmd
	Set Cmd = CreateObject("ADODB.Command")
	Cmd.ActiveConnection = Cnxn
 
	'Initialize the Log file
	Dim filesys, logFile 
	Set filesys = CreateObject("Scripting.FileSystemObject") 
	Set logFile= filesys.CreateTextFile(strLogLocTbl & "\specialTraits_" & strScope &".log", True) 
	
	logFile.WriteLine "----"
	logFile.WriteLine "Base Column: " & strColumnName
	logFile.WriteLine "HID: " & strHybridID
	logFile.WriteLine "Query: " & strSQLQuery
	logFile.WriteLine ""
 
	'set Legal Map SQL
	Dim strLegalSQL
	strLegalSQL = "select " & _
	" nID, Logo_Name, Special_Trait_Abbreviations " & _
	" from Logos_Technologies_Trademarks " & _
	" where Logo_Name is not NULL " & _
	" order by Logo_Name "
	
	logFile.WriteLine "Legal Query :"
	logFile.WriteLine strLegalSQL
 
	Cmd.CommandText = strLegalSQL
	Set lglKeywords = Cmd.Execute
 
	Dim arrLglKeys(), arrKeyIDs(), arrTraits()
	Dim kCnt
	kCnt = 0
	Dim tmpCnt, tmp2Cnt
	tmp2Cnt = 0
	
	'Initialize All Legal Keywords
	Do Until lglKeywords.EOF
 
		if Not IsEmpty(lglKeywords("Logo_Name").value) And Not lglKeywords("Logo_Name").value = "" then
			
			tmpCnt = kCnt
			kCnt = kCnt + 1
			
			ReDim Preserve arrLglKeys(kCnt)
			ReDim Preserve arrkeyIDs(kCnt)
			ReDim Preserve arrTraits(kCnt)
			arrKeyIDs(tmpCnt) = lglKeywords("nID").value
			arrLglKeys(tmpCnt) = lglKeywords("Logo_Name").value
			arrTraits(tmpCnt) = lglKeywords("Special_Trait_Abbreviations").value
		End If
	
		lglKeywords.MoveNext
	Loop
 
	'Close the Legal SQL Recordset
	if lglKeywords.State = adStateOpen then
		lglKeywords.Close
	end If
 
	'Initialize the Base Table and Column properties
	Set regPat= New RegExp
	regPat.IgnoreCase = True
	regPat.Global = True
 
	Dim strSelectCols
	Dim strFilterCol
	Dim strTable
	Dim strParent
 
	regPat.Pattern = "^Alfalfa"
	if regPat.Test(strColumnName) Then
		strSelectCols = "Alfalfa_Sunstra"
		strFilterCol = "Pertains_to_Alfalfa"
		strTable = "Alfalfa"
	End If
 
	regPat.Pattern = "^Canola"
	if regPat.Test(strColumnName) Then
		strSelectCols = "Canola_CLEARFIELD"
		strFilterCol = "Pertains_to_Canola"
		strTable = "Canola"
	End If
 
	regPat.Pattern = "^Grain_Corn"
	if regPat.Test(strColumnName) Then
		'strSelectCols = "Grain_Corn_HERCULEX_I, Grain_Corn_HERCULEX_XTRA, Grain_Corn_Roundup_Ready_2, Grain_Corn_LibertyLink, Grain_Corn_Processor_Preferred, Grain_Corn_Enhanced_Native_Protection, Grain_Corn_YieldGard_Corn_Borer, Grain_Corn_YieldGard_Plus, Grain_Corn_YieldGard_VT_Triple, Grain_Corn_YieldGard_VT_Pro, Grain_Corn_Market_Choices, Grain_Corn_IRM, Grain_Corn_Technical_Description + Grain_Corn_Marketing_Description + Grain_Corn_Management_Guideline_1 + Grain_Corn_Management_Guideline_2 + Grain_Corn_Management_Guideline_3 + Grain_Corn_Management_Guideline_4 + Grain_Corn_Management_Guideline_5 + Grain_Corn_Management_Guideline_6 + Grain_Corn_Management_Guideline_7 + Grain_Corn_Management_Guideline_8 + Grain_Corn_Management_Guideline_9 + Grain_Corn_Herb_Mgmt_Sulfonylureas_Steadfast + Grain_Corn_Herb_Mgmt_Growth_Regulators_Clarity + Grain_Corn_Herb_Mgmt_Growth_Regulators_Distinct + Grain_Corn_Herb_Mgmt_Pigment_Inhibitors_Balance_Pro + Grain_Corn_Herb_Mgmt_Pigment_Inhibitors_Callisto as Grain_Legals"
		strSelectCols = "Grain_Corn_HERCULEX_I, Grain_Corn_HERCULEX_XTRA, Grain_Corn_Roundup_Ready_2, Grain_Corn_LibertyLink, Grain_Corn_Enhanced_Native_Protection, Grain_Corn_YieldGard_Corn_Borer, Grain_Corn_YieldGard_Plus"
		strFilterCol = "Pertains_to_Grain"
		strTable = "Grain_Corn"
		'Comment the Parent so that the Special Traits come in for the Base Genetic
		'strParent = "Grain_Corn_Parent_Hybrid"
	End If
	
	regPat.Pattern = "^Silage_Corn"
	if regPat.Test(strColumnName) Then
		'strSelectCols = "Silage_Corn_LibertyLink, Silage_Corn_Roundup_Ready_2, Silage_Corn_Roundup_WeatherMax, Silage_Corn_HERCULEX_XTRA, Silage_Corn_HERCULEX_I, Silage_Corn_HERCULEX_RW, Silage_Corn_IRM, Silage_Corn_Market_Choices, Silage_Corn_Technical_Description + Silage_Corn_Marketing_Description + Silage_Corn_Management_Guideline_1 + Silage_Corn_Management_Guideline_2 + Silage_Corn_Management_Guideline_3 + Silage_Corn_Management_Guideline_4 + Silage_Corn_Management_Guideline_5 + Silage_Corn_Management_Guideline_6 +  Silage_Corn_Herb_Mgmt_Sulfonylureas_Steadfast + Silage_Corn_Herb_Mgmt_Growth_Regulators_Clarity + Silage_Corn_Herb_Mgmt_Growth_Regulators_Distinct + Silage_Corn_Herb_Mgmt_Pigment_Inhibitors_Balance_Pro + Silage_Corn_Herb_Mgmt_Pigment_Inhibitors_Callisto as Silage_Legals"
		strSelectCols = "Silage_Corn_HERCULEX_XTRA, Silage_Corn_HERCULEX_I, Silage_Corn_HERCULEX_RW, Silage_Corn_LibertyLink, Silage_Corn_Roundup_Ready_2"
		strFilterCol = "Pertains_to_Silage"
		strTable = "Silage_Corn"
		'Comment the Parent so that the Special Traits come in for the Base Genetic
		'strParent = "Silage_Corn_Parent_Hybrid"
	End If
 
	regPat.Pattern = "^Sorghum"
	if regPat.Test(strColumnName) Then
		strSelectCols = ""
		strFilterCol = "Pertains_to_Sorghum"
		strTable = "Sorghum"
	End If
 
	regPat.Pattern = "^Soybean"
	if regPat.Test(strColumnName) Then
		strSelectCols = "Soybean_Soybean_Cyst_Nematode_Logo"
		strFilterCol = "Pertains_to_Soybean"
		strTable = "Soybean"
	End If
 
	regPat.Pattern = "^Sunflower"
	if regPat.Test(strColumnName) Then
		strSelectCols = "Sunflower_Oilseed_crush_NuSun_Market, Sunflower_Oilseed_crush_Omega_9_Oils_Market, Sunflower_CLEARFIELD"
		strFilterCol = "Pertains_to_Sunflower"
		strTable = "Sunflower"
	End If
	
	regPat.Pattern = "^Supercede"
	if regPat.Test(strColumnName) Then
		strSelectCols = "Supercede_IRM, Supercede_Market_Choices, Supercede_Enhanced_Native_Protection, Supercede_LibertyLink, Supercede_HERCULEX_I, Supercede_YieldGard_VT_Triple, Supercede_YieldGard_VT_Pro, Supercede_Supercede_HE_High_Energy_Corn, Supercede_Technical_Description + Supercede_Marketing_Description + Supercede_Management_Guideline_1 + Supercede_Management_Guideline_2 + Supercede_Management_Guideline_3 + Supercede_Management_Guideline_4 + Supercede_Management_Guideline_5 + Supercede_Management_Guideline_6 + Supercede_Management_Guideline_7 + Supercede_Management_Guideline_8 + Supercede_Management_Guideline_9 + Supercede_Herb_Mgmt_Sulfonylureas_Steadfast + Supercede_Herb_Mgmt_Growth_Regulators_Clarity + Supercede_Herb_Mgmt_Growth_Regulators_Distinct + Supercede_Herb_Mgmt_Pigment_Inhibitors_Balance_Pro + Supercede_Herb_Mgmt_Pigment_Inhibitors_Callisto as Supercede_Legals "
		strFilterCol = "Pertains_to_Supercede"
		strTable = "Supercede"
		'Comment the Parent so that the Special Traits come in for the Base Genetic
		'strParent = "Supercede_Parent_Hybrid"
	End If
 
	' Override the select list if passed - useful to get indivdual TRAIT
	if Not strSelect = Empty And Not strSelect = "" Then
		strSelectCols = strSelect
	End If
	
	if strParent = "" Or IsEmpty(strParent) Then
		logFile.WriteLine "Warning :: Parent Column in Query not chosen "
		
		'Main SQL Query to derive all the Base Genetics
		strSQLQuery = "SELECT " & strColumnName & ", " & strSelectCols & _
			" FROM " & strTable & _
			" where " & strColumnName & " like '" & _
			strHybridID + "'"
	Else
		'Main SQL Query to derive all the Base Genetics
		strSQLQuery = "SELECT " & strColumnName & ", " & strSelectCols & _
			" FROM " & strTable & _
			" where " & strParent & " = ( select " & strParent & _
			" from " & strTable & _
			" WHERE " & strColumnName & " like '" & _
			strHybridID + "')" & _
			" AND " & strColumnName & " not like '" & _
			strHybridID + "'"
	End If
	
	logFile.WriteLine ""
	logFile.WriteLine "Master Query:: " & strSQLQuery
				
	Cmd.CommandText = strSQLQuery
    Set lglTraits = Cmd.Execute
	Dim strHXI, strHXX, strHXRW, strRR, strRR2, strRRWM, strLL, strPP, strENP, strYGCB, strYGP, strYGVT, strYGVTP, strMC, strIRM, strSunstra, strClrFldCan, strClrFldSun, strSTS, strCNL, strOCNM, strOCO9OM, strSHEC
 
	'Main storage strings
	Dim strBrands, strReturn
	strReturn = " "
	
	Do Until lglTraits.EOF
 
		strHXI = Empty
		strHXX = Empty
		strHXRW = Empty
		strRR = Empty
		strRR2 = Empty
		strRRWM = Empty
		strLL = Empty
		strPP = Empty
		strENP = Empty
		strYGCB = Empty
		strYGP = Empty
		strYGVT = Empty
		strYGVTP = Empty
		strMC = Empty
		strIRM = Empty
		strSunstra = Empty
		strClrFldCan = Empty
		strClrFldSun = Empty
		strSTS = Empty
		strCNL = Empty
		strOCNM = Empty
		strOCO9OM = Empty
		strSHEC = Empty
 
		If strTable = "Grain_Corn" Or strTable = "Silage_Corn" Or strTable = "Supercede" Then
 
			regPat.Pattern = strTable & "_HERCULEX_I"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_HERCULEX_I")) And lglTraits(strTable & "_HERCULEX_I").value = "X" then
					strHXI = "1"
				end if
			end If
 
			regPat.Pattern = strTable & "_LibertyLink"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_LibertyLink")) And lglTraits(strTable & "_LibertyLink").value = "X" then
					strLL = "1"
				end if
			end If
 
			if strTable = "Silage_Corn" Or strTable = "Supercede" Then
				regPat.Pattern = strTable & "_IRM"
				if regPat.Test(strSelectCols) Then
					If Not IsNull(lglTraits(strTable & "_IRM")) And lglTraits(strTable & "_IRM").value = "X" then
						strIRM = "1"
					end if
				end If
 
				regPat.Pattern = strTable & "_Market_Choices"
				if regPat.Test(strSelectCols) Then
					If Not IsNull(lglTraits(strTable & "_Market_Choices")) And lglTraits(strTable & "_Market_Choices").value = "X" then
						strMC = "1"
					end if
				end If
			end if
		End If
 
		If strTable = "Grain_Corn" Or strTable = "Supercede" Then
			regPat.Pattern = strTable & "_Enhanced_Native_Protection"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Enhanced_Native_Protection")) And lglTraits(strTable & "_Enhanced_Native_Protection").value = "X" then
					strENP = "1"
				end if
			end If
 
			if strTable = "Supercede" Then
				regPat.Pattern = strTable & "_YieldGard_VT_Triple"
				if regPat.Test(strSelectCols) Then
					If Not IsNull(lglTraits(strTable & "_YieldGard_VT_Triple")) And lglTraits(strTable & "_YieldGard_VT_Triple").value = "X" then
						strYGVT = "1"
					end if
				end If
 
				regPat.Pattern = strTable & "_YieldGard_VT_Pro"
				if regPat.Test(strSelectCols) Then
					If Not IsNull(lglTraits(strTable & "_YieldGard_VT_Pro")) And lglTraits(strTable & "_YieldGard_VT_Pro").value = "X" then
						strYGVTP = "1"
					end if
				end If
			end if
		End If
 
		if strTable = "Grain_Corn" Or strTable = "Silage_Corn" Then
			regPat.Pattern = strTable & "_HERCULEX_XTRA"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_HERCULEX_XTRA")) And lglTraits(strTable & "_HERCULEX_XTRA").value = "X" then
					strHXX = "1"
				end if
			end If
 
			regPat.Pattern = strTable & "_Roundup_Ready_2"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Roundup_Ready_2")) And lglTraits(strTable & "_Roundup_Ready_2").value = "X" then
					strRR2 = "1"
				end if
			end If
		End If
 
		If strTable = "Silage_Corn" Then
			regPat.Pattern = strTable & "_Roundup_WeatherMax"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Roundup_WeatherMax")) And lglTraits(strTable & "_Roundup_WeatherMax").value = "X" then
					strRRWM = "1"
				end if
			end If
 
			regPat.Pattern = strTable & "_HERCULEX_RW"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_HERCULEX_RW")) And lglTraits(strTable & "_HERCULEX_RW").value = "X" then
					strHXRW = "1"
				end if
			end If
		End If
 
		If strTable = "Grain_Corn" Then
			regPat.Pattern = strTable & "_Processor_Preferred"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Processor_Preferred")) And lglTraits(strTable & "_Processor_Preferred").value = "X" then
					strPP = "1"
				end if
			end If
 
			regPat.Pattern = strTable & "_YieldGard_Corn_Borer"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_YieldGard_Corn_Borer")) And lglTraits(strTable & "_YieldGard_Corn_Borer").value = "X" then
					strYGCB = "1"
				end if
			end If
 
			regPat.Pattern = strTable & "_YieldGard_Plus"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_YieldGard_Plus")) And lglTraits(strTable & "_YieldGard_Plus").value = "X" then
					strYGP = "1"
				end if
			end If
		End If
 
		if strTable = "Alfalfa" Then
			regPat.Pattern = strTable & "_Sunstra"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Sunstra")) And lglTraits(strTable & "_Sunstra").value = "X" then
					strSunstra = "1"
				end if
			end If
		End If
 
		if strTable = "Canola" Then
			regPat.Pattern = strTable & "_CLEARFIELD"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_CLEARFIELD")) And lglTraits(strTable & "_CLEARFIELD").value = "X" then
					strClrFldCan = "1"
				end if
			end If
		End If
 
		if strTable = "Sunflower" Then
			regPat.Pattern = strTable & "_CLEARFIELD"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_CLEARFIELD")) And lglTraits(strTable & "_CLEARFIELD").value = "X" then
					strClrFldSun = "1"
				end if
			end If
		End If
 
		If strTable = "Soybean" Then
			regPat.Pattern = strTable & "_Roundup_Ready"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Roundup_Ready")) And lglTraits(strTable & "_Roundup_Ready").value = "X" then
					strRR = "1"
				end if
			end If
 
			regPat.Pattern = strTable & "_STS"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_STS")) And lglTraits(strTable & "_STS").value = "X" then
					strSTS = "1"
				end if
			end If
 
			regPat.Pattern = strTable & "_Soybean_Cyst_Nematode_Logo"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Soybean_Cyst_Nematode_Logo")) And lglTraits(strTable & "_Soybean_Cyst_Nematode_Logo").value = "X" then
					strCNL = "1"
				end if
			end If
		End If
 
		If strTable = "Sunflower" Then
			regPat.Pattern = strTable & "_Oilseed_crush_NuSun_Market"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Oilseed_crush_NuSun_Market")) And lglTraits(strTable & "_Oilseed_crush_NuSun_Market").value = "X" then
					strOCNM = "1"
				end if
			end If
			
			regPat.Pattern = strTable & "_Oilseed_crush_Omega_9_Oils_Market"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Oilseed_crush_Omega_9_Oils_Market")) And lglTraits(strTable & "_Oilseed_crush_Omega_9_Oils_Market").value = "X" then
					strOCO9OM= "1"
				end if
			end If
		End If
		
		If strTable = "Supercede" Then
			regPat.Pattern = strTable & "_Supercede_HE_High_Energy_Corn"
			if regPat.Test(strSelectCols) Then
				If Not IsNull(lglTraits(strTable & "_Supercede_HE_High_Energy_Corn")) And lglTraits(strTable & "_Supercede_HE_High_Energy_Corn").value = "X" then
					strSHEC = "1"
				end if
			end If
		End If
 
		'Parse the Legal Traits and set from the Array
		strBrands = Empty
		Dim tCnt
		for tCnt = 0 to kCnt
			Select Case arrLglKeys(tCnt)
				Case "HERCULEX I Insect Protection"
					if Not IsEmpty(strHXI) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "HXI - " & strHXI
					end if
				Case "HERCULEX XTRA Insect Protection"
					if Not IsEmpty(strHXX) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "HXX - " & strHXX
					end if
				Case "HERCULEX RW Rootworm Protection"
					if Not IsEmpty(strHXRW) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "HXRW - " & strHXRW
					End If
				Case "Roundup Ready Soybeans"
					if Not IsEmpty(strRR) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "RR - " & strRR
					end If
				Case "Roundup Ready Corn 2"
					if Not IsEmpty(strRR2) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "RR2 - " & strRR2
					end If
				Case "LibertyLink Herbicide Resistance"
					if Not IsEmpty(strLL) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "HXX - " & strHXX
					end If
				Case "Processor Preferred"
					if Not IsEmpty(strPP) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "PP - " & strPP
					end If
				Case "Enhanced Native Protection"
					if Not IsEmpty(strENP) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "ENP - " & strENP
					end If
				Case "YieldGard Corn Borer"
					if Not IsEmpty(strYGCB) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "YGCB- " & strYGCB
					end If
				Case "YieldGard Plus"
					if Not IsEmpty(strYGP) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "YGP - " & strYGP
					end If
				Case "YieldGard VT Triple"
					if Not IsEmpty(strYGVT) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "HXX - " & strHXX
					end If
				Case "YieldGard VT Pro"
					if Not IsEmpty(strYGVTP) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "YGVTP - " & strYGVTP
					end If
				Case "Market Choices"
					if Not IsEmpty(strMC) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "MC - " & strMC
					end If
				Case "Hybrid alfalfa"
					if Not IsEmpty(strSunstra) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "Alfalfa_Sunstra - " & strSunstra
					end If
				Case "Clearfield Production System-Canola"
					if Not IsEmpty(strClrFldCan) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "ClrFldCan - " & strClrFldCan
					end If
				Case "Clearfield Production System-Sunflower"
					if Not IsEmpty(strClrFldSun) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "ClrFldSun - " & strClrFldSun
					end If
				Case "Roundup WeatherMAX herbicide/Roundup Ready Corn2"
					if Not IsEmpty(strRRWM) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "RRWM - " & strRRWM
					end If
				Case "Insect Resistance Management"
					if Not IsEmpty(strIRM) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "IRM - " & strIRM
					end If
				Case "Sulfonylurea Tolerant Soybean"
					if Not IsEmpty(strSTS) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "STS - " & strSTS
					end If
				Case "Cyst Nematode"
					if Not IsEmpty(strCNL) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "CNL - " & strCNL
					end If
				Case "Oilseed crush/NuSun"
					if Not IsEmpty(strOCNM) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "OCNM - " & strOCNM
					end If
				Case "Oilseed crush/Omega-9 Oils"
					if Not IsEmpty(strOCO9OM) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "OCO9OM- " & strOCO9OM
					end If
				Case "Supercede HE High Energy Corn"
					if Not IsEmpty(strSHEC) Then
						If Not IsEmpty(strBrands) Then
							strBrands = strBrands & "/"
						End If
						strBrands = strBrands & arrTraits(tCnt)
						logFile.WriteLine "SHEC - " & strSHEC
					end If
				Case Else
					logFile.WriteLine "Missing lOGO NAME"
			End Select			
		Next
		
		logFile.WriteLine "Base Traits - " & strBrands
 
		'Dim strBaseHID
		'strBaseHID = lglTraits(strTable & "_Hybrids_with_Same_Base_Genetics").value
		'logFile.WriteLine "Base HID - " & strBaseHID
		'If Not IsEmpty(strBaseHID) Then
			'strReturn = strReturn & strBaseHID
		'End If
 
		If Not IsEmpty(strBrands) Then
			strReturn = strBrands
		End If
				
		lglTraits.MoveNext 
    Loop
 
	If lglTraits.State = adStateOpen then
        lglTraits.Close
    End If
    
 
	'Close the SQL Connection completely
	If Cnxn.State = adStateOpen then
        Cnxn.Close
    End If
	
	logFile.WriteLine "strReturn - " & strReturn
	logFile.Close
    
	Set Cmd = Nothing
    Set lglTraits = Nothing
    Set Cnxn = Nothing
 
	getSpecialTraits = strReturn
End Function
'End of Special Traits
 
'main function to be used in PFlex Studio
Function GetFmtTables (stHIDs, strColumnName, strChart, sPageNum, sPageSize)
    
	GetFmtTables = ""
	Dim strBaseGen
	Dim strHybridIDs
	strHybridIDs = stHIDs
	
	Dim nPageNum, nPageSize
	nPageNum = CInt(sPageNum)
	nPageSize = CInt(sPageSize)
 
	Dim pageSize
	pageSize = 15
 
	Dim pageNum
	pageNum = 1
	
	Dim strEmpty
	strEmpty = ""
 
	'Has to RETURN if empty Chart Type
	if IsEmpty(strChart) Or strChart = "" then
		GetFmtTables = strEmpty
		Exit Function
	end If
 
	'Default other variables
	if IsNull(nPageSize) Or IsEmpty(nPageSize) Or nPageSize = "" Or nPageSize = 0 then
		nPageSize = pageSize
	end If
 
	'Default other variables
	if IsNull(nPageNum) Or IsEmpty(nPageNum) Or nPageNum = "" Or nPageNum = 0 then
		nPageNum = -1
	end If
 
	Set regPat= New RegExp
	regPat.IgnoreCase = True
	regPat.Global = True
 
	'Has to RETURN if empty HybridID
	regPat.Pattern = "^[\s\t ]+$"
	if IsEmpty(strHybridIDs) Or strHybridIDs = "" Or regPat.Test(strHybridIDs) then
		GetFmtTables = strEmpty
		Exit Function
	end If
 
	strScope = strChart
 
	Dim strSelectCols, strTable, strOrderBy
	strOrderBy = strColumnName
	
	'Set the Base Properties for SQL Query
	regPat.Pattern = "^Alfalfa"
	if regPat.Test(strColumnName) Then
		strSelectCols = " Alfalfa_Sunstra "
		strTable = "Alfalfa"
	End If
 
	regPat.Pattern = "^Canola"
	if regPat.Test(strColumnName) Then
		strSelectCols = "Canola_CLEARFIELD "
		strTable = "Canola"
	End If
 
	regPat.Pattern = "^Grain_Corn"
	if regPat.Test(strColumnName) Then
		strTable = "Grain_Corn"
	End If
 
	regPat.Pattern = "^Silage_Corn"
	if regPat.Test(strColumnName) Then
		strTable = "Silage_Corn"
	End If
 
	regPat.Pattern = "^Sorghum"
	if regPat.Test(strColumnName) Then
		strTable = "Sorghum"
	End If
 
	regPat.Pattern = "^Soybean"
	if regPat.Test(strColumnName) Then
		strTable = "Soybean"
	End If
 
	regPat.Pattern = "^Sunflower"
	if regPat.Test(strColumnName) Then
		strTable = "Sunflower"
	End If
	
	regPat.Pattern = "^Supercede"
	if regPat.Test(strColumnName) Then
		strTable = "Supercede"
	End If
	
	regPat.Pattern = "Herbicide Management"
	if regPat.Test(strChart) Then
		strOrderBy = strTable & "_Relative_Maturity"
	End If
 
	'set Legal Map SQL
	Dim strSQL
	strSQL = "select * " & _
	" from " & strTable & _
	" where " & strColumnName & " in (" & _
	strHybridIDs & ") " & _
	" order by " & strOrderBy
 
	Dim strTag
	strTag = "Row_Chart"
	regPat.Pattern = "^Alfalfa Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_Alf_Char"
	End If
	regPat.Pattern = "^Canola Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_Can_Char"
	End If
	regPat.Pattern = "^Grain Corn Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_GC_Char"
	End If
	regPat.Pattern = "^Grain Corn Conversion"
	if regPat.Test(strChart) Then
		strTag = "Row_GC_Char"
	End If
	regPat.Pattern = "^Grain Corn Positioning"
	if regPat.Test(strChart) Then
		strTag = "Row_GC_Pos"
	End If
	regPat.Pattern = "^Silage Corn Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_Sil_Char"
	End If
	regPat.Pattern = "Sorghum Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_Sorg_Char"
	End If
	regPat.Pattern = "^Soybean Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_Soy_Char"
	End If
	regPat.Pattern = "^Sunflower Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_Sun_Char"
	End If
	regPat.Pattern = "^Supercede Characteristics"
	if regPat.Test(strChart) Then
		strTag = "Row_Sup_Char"
	End If
	regPat.Pattern = "^Grain Corn Herbicide Management"
	if regPat.Test(strChart) Then
		strTag = "Row_GC_Herb"
	End If
	regPat.Pattern = "^Silage Corn Herbicide Management"
	if regPat.Test(strChart) Then
		strTag = "Row_Sil_Herb"
	End If
	regPat.Pattern = "^Supercede Herbicide Management"
	if regPat.Test(strChart) Then
		strTag = "Row_Sup_Herb"
	End If
	
	regPat.Pattern = "^Grain Corn Conversion"
	if regPat.Test(strChart) Then
		strTag = "Row_GC_Conv"
		'Special Handle the Query for Grain Corn Trait Conversion
		strSQL = "select * from VIEW_GC_TRAIT_CONVERSION " & _
			" where Grain_Corn_Hybrids_With_Same_Base_Genetics in ( " & strHybridIDs & ") " & _
			" order by Grain_Corn_Parent_Hybrid, dbo.parseInt(Grain_Corn_Relative_Maturity) "
	End If
	
	'Initialize the Log file
	Dim filesys, logFile
	Dim strPath
	strPath = strLogLocTbl & "\getFmtTables_" & strChart
	Dim strExt
	strExt = ".log"
	
	On Error Resume Next
	Set filesys = CreateObject("Scripting.FileSystemObject")
	Set logFile= filesys.CreateTextFile(strPath & strExt, True)
 
	If Not IsNull(logFile) Then
		logFile.WriteLine "----"
		logFile.WriteLine "Base Column: " & strColumnName
		logFile.WriteLine "Base Table: " & strTable
		logFile.WriteLine "HID: " & strHybridIDs
		logFile.WriteLine ""
		logFile.WriteLine "FmtTable Query : " & strSQL
	End If
	
	Dim Cnxn
	' Create and open SQL Connection
	Set Cnxn = CreateObject("ADODB.Connection") 
	Cnxn.Open  strCnxnTbl
 
	Dim Cmd
	Set Cmd = CreateObject("ADODB.Command")
	Cmd.ActiveConnection = Cnxn
 
	Cmd.CommandText = strSQL
    Dim arrHybrid
	Set arrHybrid = Cmd.Execute
 
	Dim kCnt
	kCnt = 0
	
	'Initialize All Legal arrHybrid
	Dim strRes
	strRes = ""
	Dim strLastParent, strRM, strConventional, strLastBaseGen, strLastGenFam
	strLastParent = ""
	strRM = ""
	strConventional = ""
	strLastBaseGen = ""
	strLastGenFam = ""
	Dim strHXX_RR_LL, strHXX_LL, strHXI_RR_LL, strHXI_LL, strENP, strYGVT, strYGP_RR, strYGP, strRR, strLL, strCL
	
	'store Grain Corn Conversion in an Array and sort per Relative Maturity later
	Dim arrConvRows()
	Dim convCount
	convCount = 0
	
	'Parse all Hybrids found
	Do Until arrHybrid.EOF
 
		regPat.Pattern = "^Grain Corn Conversion"
		if Not regPat.Test(strChart) Then
			strRes = strRes & "<" & strTag
			if kCnt Mod 2 = 0 Then
				strRes = strRes & "_On"
			Else
				strRes = strRes & "_Off"
			End If
			strRes = strRes & ">"
			strRes = strRes & "&NDtab;"
		End If
 
		'Set the Base Properties for SQL Query
		regPat.Pattern = "^Alfalfa Characteristics"
		if regPat.Test(strChart) Then
 
			strRes = strRes & arrHybrid("Alfalfa_Variety_Number").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Alfalfa_Winterhardiness").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Alfalfa_Fall_Dormancy").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Alfalfa_Cutting_Recovery").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Alfalfa_Yield_Level").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Alfalfa_Forage_Quality").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Alfalfa_Cuttings_Per_Season").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Alfalfa_Disease_Rating_Index").Value
			strRes = strRes & "&NDtab;"
			
			strTemp = ""
			if arrHybrid("Alfalfa_Phytophthora_Root_Rot").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Phytophthora_Root_Rot").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Phytophthora_Root_Rot").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Phytophthora_Root_Rot").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Phytophthora_Root_Rot").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
		
			strTemp = ""
			if arrHybrid("Alfalfa_Aphanomyces_Race_1").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_1").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_1").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_1").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_1").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
		
			strTemp = ""
			if arrHybrid("Alfalfa_Aphanomyces_Race_2").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_2").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_2").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_2").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Aphanomyces_Race_2").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
				
			strTemp = ""
			if arrHybrid("Alfalfa_Bacterial_Wilt").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Bacterial_Wilt").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Bacterial_Wilt").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Bacterial_Wilt").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Bacterial_Wilt").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
		
			strTemp = ""
			if arrHybrid("Alfalfa_Anthracnose").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Anthracnose").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Anthracnose").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Anthracnose").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Anthracnose").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Alfalfa_Verticillium_Wilt").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Verticillium_Wilt").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Verticillium_Wilt").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Verticillium_Wilt").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Verticillium_Wilt").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Alfalfa_Fusarium_Wilt").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Fusarium_Wilt").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Fusarium_Wilt").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Fusarium_Wilt").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Fusarium_Wilt").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Alfalfa_Pea_Aphid").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Pea_Aphid").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Pea_Aphid").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Pea_Aphid").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Pea_Aphid").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Alfalfa_Spotted_Alfalfa_Aphid").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Spotted_Alfalfa_Aphid").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Spotted_Alfalfa_Aphid").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Spotted_Alfalfa_Aphid").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Spotted_Alfalfa_Aphid").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Alfalfa_Stem_Nematode").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Stem_Nematode").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Stem_Nematode").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Stem_Nematode").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Stem_Nematode").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Alfalfa_Potato_Leafhopper").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Alfalfa_Potato_Leafhopper").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Alfalfa_Potato_Leafhopper").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Alfalfa_Potato_Leafhopper").Value = "Low Resistant" Then
				strTemp = "LR"
			End If
			if arrHybrid("Alfalfa_Potato_Leafhopper").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
			
		End If
 
		regPat.Pattern = "^Canola Characteristics"
		if regPat.Test(strChart) Then
 
			strRes = strRes & arrHybrid("Canola_Variety_Number").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Canola_New").Value = "X" Then
				strTemp = "NEW"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strBaseGen = ""
			strBaseGen = getSpecialTraits(arrHybrid("Canola_Variety_Number").Value, strColumnName, "Canola_CLEARFIELD")
			If Len(strBaseGen) > 10 Then
				strBaseGen = "<BaseGen>" & strBaseGen & "</BaseGen>"
			End If
			strRes = strRes & strBaseGen
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Canola_Plant_Height").Value = "Medium" Then
				strTemp = "M"
			End If
			if arrHybrid("Canola_Plant_Height").Value = "Medium Tall" Or arrHybrid("Canola_Plant_Height").Value = "Medium/Tall" Then
				strTemp = "MT"
			End If
			if arrHybrid("Canola_Plant_Height").Value = "Tall" Then
				strTemp = "T"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Canola_Standability").Value = "Very Good" Then
				strTemp = "VG"
			End If
			if arrHybrid("Canola_Standability").Value = "Bad" Then
				strTemp = "B"
			End If
			if arrHybrid("Canola_Standability").Value = "Good" Then
				strTemp = "G"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Canola_Blackleg_Resistance_Rating").Value = "Highly Resistant" Then
				strTemp = "HR"
			End If
			if arrHybrid("Canola_Blackleg_Resistance_Rating").Value = "Moderately Resistant" Then
				strTemp = "MR"
			End If
			if arrHybrid("Canola_Blackleg_Resistance_Rating").Value = "Resistant" Then
				strTemp = "R"
			End If
			if arrHybrid("Canola_Blackleg_Resistance_Rating").Value = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Canola_Early_Season_Vigor").Value = "Very Good" Then
				strTemp = "VG"
			End If
			if arrHybrid("Canola_Early_Season_Vigor").Value = "Bad" Then
				strTemp = "B"
			End If
			if arrHybrid("Canola_Early_Season_Vigor").Value = "Good" Then
				strTemp = "G"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
		End If
 
		regPat.Pattern = "^Grain Corn Characteristics"
		if regPat.Test(strChart) Then
			
			strRes = strRes & arrHybrid("Grain_Corn_Hybrids_With_Same_Base_Genetics").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Grain_Corn_Parent_Hybrid").Value
			strRes = strRes & "&NDtab;"
		
			strBaseGen = ""
			strBaseGen = getSpecialTraits(arrHybrid("Grain_Corn_Hybrids_With_Same_Base_Genetics").Value, strColumnName, "")
			If Len(strBaseGen) > 10 Then
				strBaseGen = "<BaseGen>" & strBaseGen & "</BaseGen>"
			End If
			
			strRes = strRes & strBaseGen
			strRes = strRes & "&NDtab;"
			
			strRes = strRes & arrHybrid("Grain_Corn_Relative_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Relative_Maturity_Range").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_GDUs_To_Mid_Silk").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_GDUs_To_Blacklayer").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Emergence").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Early_Vigor").Value
			strRes = strRes & "&NDtab;"
 
			Dim strTemp
			strTemp = ""
			if arrHybrid("Grain_Corn_Plant_Height").Value = "Tall" Then
				strTemp = "T"
			End If
			if arrHybrid("Grain_Corn_Plant_Height").Value = "Medium/Tall" Or arrHybrid("Grain_Corn_Plant_Height").Value = "Medium Tall" Then
				strTemp = "MT"
			End If
			if arrHybrid("Grain_Corn_Plant_Height").Value = "Medium" Then
				strTemp = "M"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
			
			strTemp = ""
			if arrHybrid("Grain_Corn_Ear_Height").Value = "Medium" Then
				strTemp = "M"
			End If
			if arrHybrid("Grain_Corn_Ear_Height").Value = "High" Then
				strTemp = "H"
			End If
			if arrHybrid("Grain_Corn_Ear_Height").Value = "Moderately High" Then
				strTemp = "MH"
			End If
			if arrHybrid("Grain_Corn_Ear_Height").Value = "Moderately Low" Then
				strTemp = "ML"
			End If
			if arrHybrid("Grain_Corn_Ear_Height").Value = "Low" Then
				strTemp = "L"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Ear_Type").Value = "Fixed" Then
				strTemp = "FIXED"
			End If
			if arrHybrid("Grain_Corn_Ear_Type").Value = "Flexible" Then
				strTemp = "FLEX"
			End If
			if arrHybrid("Grain_Corn_Ear_Type").Value = "Semi-flexible" Then
				strTemp = "SEMI"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Test_Weight").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Drought_Tolerance").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Staygreen").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Stalk_Strength").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Root_Strength").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Greensnap").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Drydown").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Ear_Retention").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Grain_Corn_Gray_Leaf_Spot").Value
			if strTemp = "Not Rated" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Grain_Corn_Eyespot").Value
			if strTemp = "Not Rated" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
		End If
 
		regPat.Pattern = "^Grain Corn Conversion"
		if regPat.Test(strChart) Then
		
			strLastBaseGen = arrHybrid("Grain_Corn_Hybrids_With_Same_Base_Genetics").Value
			strLastGenFam = arrHybrid("Grain_Corn_Genetic_Family_Group").Value
 
			if IsEmpty(strLastParent) Or strLastParent = "" Or Not strLastparent = arrHybrid("Grain_Corn_Parent_Hybrid") Then
				
				'Update the Master String  - Add a row if Parent is completely loaded
				If Not strLastParent = "" And Not IsEmpty(strLastParent) Then
					
					strBaseGen = "&NDtab;" & _ 
								strLastParent & "&NDtab;" & _
								strRM & "&NDtab;" & _
								strLastGenFam & "&NDtab;" & _
								strConventional & "&NDtab;" & _
								strHXX_RR_LL & "&NDtab;" & _
								strHXX_LL & "&NDtab;" & _
								strHXI_RR_LL & "&NDtab;" & _
								strHXI_LL & "&NDtab;" & _
								strENP & "&NDtab;" & _
								strYGVT & "&NDtab;" & _
								strYGP_RR & "&NDtab;" & _
								strYGP & "&NDtab;" & _
								strRR & "&NDtab;" & _
								strLL & "&NDtab;" & _
								strCL
					
					'Add a new Row
 
					strRes = "<" & strTag
					if kCnt Mod 2 = 0 Then
						strRes = strRes & "_On"
					Else
						strRes = strRes & "_Off"
					End If
					strRes = strRes & ">"
					strRes = strRes & strBaseGen
					strRes = strRes & "</" & strTag
					if kCnt Mod 2 = 0 Then
						strRes = strRes & "_On"
					Else
						strRes = strRes & "_Off"
					End If
					strRes = strRes & ">"
 
					kCnt = kCnt + 1
 
					'Add a new page
					if kCnt Mod nPageSize = 0 Then
						If Not IsNull(logFile) Then
							logFile.WriteLine ""
							logFile.WriteLine "Breathe1 pageNum = " & pageNum & ", nPageNum = " & nPageNum & ", pageSize = " & pageSize & ", nPageSize = " & nPageSize & ", kCnt = " & kCnt
							logFile.WriteLine ""
						End If
						pageNum = pageNum + 1
					End If
 
					'Add to the Conv array
					ReDim Preserve arrConvRows(convCount + 1)
					arrConvRows(convCount) = strRM & ":" & strRes
					convCount = convCount + 1
					
					'Reset the Strings
					strConventional = ""
					strHXX_RR_LL = ""
					strHXX_LL = ""
					strHXI_RR_LL = ""
					strHXI_LL = ""
					strENP = ""
					strYGVT = ""
					strYGP_RR = ""
					strYGP = ""
					strRR = ""
					strLL = ""
					strCL  = ""					
				End If
				
				'Update the parent string
				strLastParent = arrHybrid("Grain_Corn_Parent_Hybrid").Value
			End If
			
			'Debug Stmtm for Conventional
			If Not IsNull(logFile) Then
				logFile.WriteLine arrHybrid("Grain_Corn_Parent_Hybrid") & " :: " & strLastBaseGen & ": " & arrHybrid("HXX_RR_LL").Value & "," & arrHybrid("HXX_LL").Value & "," & arrHybrid("HXI_RR_LL").Value & "," & arrHybrid("HXI_LL").Value & "," & arrHybrid("ENP").Value & "," & arrHybrid("YGVT").Value & "," & arrHybrid("YGP_RR").Value & "," & arrHybrid("YGP").Value & "," & arrHybrid("RR").Value & "," & arrHybrid("LL").Value & ",CLF:" & arrHybrid("CLF").Value & "."
			End If
 
			if arrHybrid("Grain_Corn_Parent_Hybrid") = strLastBaseGen THen
				strRM = arrHybrid("Grain_Corn_Relative_Maturity")
				
				'Set the Conventional Hybrid
				'logFile.WriteLine "  ... trying HXX_RR_LL : " & arrHybrid("Grain_Corn_Parent_Hybrid")
				if IsEmpty(arrHybrid("HXX_RR_LL").Value) Or arrHybrid("HXX_RR_LL").Value = "" Then
					'logFile.WriteLine "  ... trying HXX_LL : " & arrHybrid("Grain_Corn_Parent_Hybrid")
					if IsEmpty(arrHybrid("HXX_LL").Value) Or arrHybrid("HXX_LL").Value = "" Then
						'logFile.WriteLine "  ... trying HXI_RR_LL : " & arrHybrid("Grain_Corn_Parent_Hybrid")
						if IsEmpty(arrHybrid("HXI_RR_LL").Value) Or arrHybrid("HXI_RR_LL").Value = "" Then
							'logFile.WriteLine "  ... trying HXI_LL : " & arrHybrid("Grain_Corn_Parent_Hybrid")
							if IsEmpty(arrHybrid("HXI_LL").Value) Or arrHybrid("HXI_LL").Value = "" Then
								'logFile.WriteLine "  ... trying ENP : " & arrHybrid("Grain_Corn_Parent_Hybrid")
								if IsEmpty(arrHybrid("ENP").Value) Or arrHybrid("ENP").Value = "" Then
									'logFile.WriteLine "  ... trying YGVT : " & arrHybrid("Grain_Corn_Parent_Hybrid")
									if IsEmpty(arrHybrid("YGVT").Value) Or arrHybrid("YGVT").Value = "" Then
										'logFile.WriteLine "  ... trying YGP_RR : " & arrHybrid("Grain_Corn_Parent_Hybrid")
										if IsEmpty(arrHybrid("YGP_RR").Value) Or arrHybrid("YGP_RR").Value = "" Then
											'logFile.WriteLine "  ... trying YGP : " & arrHybrid("Grain_Corn_Parent_Hybrid")
											if IsEmpty(arrHybrid("YGP").Value) Or arrHybrid("YGP").Value = "" Then
												'logFile.WriteLine "  ... trying RR : " & arrHybrid("Grain_Corn_Parent_Hybrid")
												if IsEmpty(arrHybrid("RR").Value) Or arrHybrid("RR").Value = "" Then
													'logFile.WriteLine "  ... trying LL : " & arrHybrid("Grain_Corn_Parent_Hybrid")
													if IsEmpty(arrHybrid("LL").Value) Or arrHybrid("LL").Value = "" Then
														'logFile.WriteLine "  ... trying CL : " & arrHybrid("Grain_Corn_Parent_Hybrid")
														if IsEmpty(arrHybrid("CLF").Value) Or arrHybrid("CLF").Value = "" Then
															logFile.WriteLine "Setting Conventional : " & arrHybrid("Grain_Corn_Parent_Hybrid")
															strConventional = arrHybrid("Grain_Corn_Parent_Hybrid")
														End If
													End If
												End If
											End If
										End If
									End If
								End If
							End If
						End If
					End If
				Else
					strConventional = ""
				End If
			Else
				strRM = arrHybrid("Grain_Corn_Relative_Maturity")
			End If
			
			'Concat the latest hybrid Ids to the respective column strings
			Dim bIgnoreRR, bIgnoreLL, bIgnoreYGP, bIgnoreHXX, bIgnoreHXI
			bIgnoreRR = 0
			bIgnoreLL = 0
			bIgnoreYGP = 0
			bIgnoreHXX = 0
			bIgnoreHXI = 0
			
			if arrHybrid("HXX_RR_LL").Value = "XXX" Then
				if Not IsEmpty(strHXX_RR_LL) And Not strHXX_RR_LL = "" Then
					strHXX_RR_LL = strHXX_RR_LL & ", "
				end if
				strHXX_RR_LL = strHXX_RR_LL & strLastBaseGen
				bIgnoreRR = 1
				bIgnoreLL = 1
				bIgnoreHXX = 1
			End If
			
			if arrHybrid("HXX_LL").Value = "XX"  And bIgnoreHXX = 0 Then
				if Not IsEmpty(strHXX_LL) And Not strHXX_LL = "" Then
					strHXX_LL = strHXX_LL & ", "
				end if
				strHXX_LL = strHXX_LL & strLastBaseGen
				bIgnoreLL = 1
				bIgnoreHXX = 1
			End If
			
			if arrHybrid("HXI_RR_LL").Value = "XXX" then
				if Not IsEmpty(strHXI_RR_LL) And Not strHXI_RR_LL = "" Then
					strHXI_RR_LL = strHXI_RR_LL & ", "
				end if
				strHXI_RR_LL = strHXI_RR_LL & strLastBaseGen
				bIgnoreRR = 1
				bIgnoreLL = 1
				bIgnoreHXI = 1
			End If
			
			if arrHybrid("HXI_LL").Value = "XX" And bIgnoreHXI = 0 Then
				if Not IsEmpty(strHXI_LL) And Not strHXI_LL = "" Then
					strHXI_LL = strHXI_LL & ", "
				end if
				strHXI_LL = strHXI_LL & strLastBaseGen
				bIgnoreLL = 1
				bIgnoreHXI = 1
			End If
			
			if arrHybrid("ENP").Value = "X" Then
				if Not IsEmpty(strENP) And Not strENP = "" Then
					strENP = strENP & ", "
				end if
				strENP = strENP & strLastBaseGen
			End If
			
			if arrHybrid("YGVT").Value = "X" Then
				if Not IsEmpty(strYGVT) And Not strYGVT = "" Then
					strYGVT = strYGVT & ", "
				end if
				strYGVT = strYGVT & strLastBaseGen
			End if
			
			if arrHybrid("YGP_RR").Value = "XX" Then
				if Not IsEmpty(strYGP_RR) And Not strYGP_RR = "" Then
					strYGP_RR = strYGP_RR & ", "
				end if
				strYGP_RR = strYGP_RR & strLastBaseGen
				bIgnoreRR = 1
				bIgnoreYGP = 1
			end If
			
			if arrHybrid("YGP").Value = "X" And bIgnoreYGP = 0 Then
				if Not IsEmpty(strYGP) And Not strYGP = "" Then
					strYGP = strYGP & ", "
				end if
				strYGP = strYGP & strLastBaseGen
			end If
			
			if arrHybrid("RR").Value = "X" And bIgnoreRR = 0 Then
				if Not IsEmpty(strRR) And Not strRR = "" Then
					strRR = strRR & ", "
				end if
				strRR = strRR & strLastBaseGen
			End If
			
			if arrHybrid("LL").Value = "X" And bIgnoreLL = 0 Then
				if Not IsEmpty(strLL) And Not strLL = "" Then
					strLL = strLL & ", "
				end if
				strLL = strLL & strLastBaseGen
			End If
			
			If arrHybrid("CLF").Value = "X" Then
				if Not IsEmpty(strCL) And Not strCL = "" Then
					strCL = strCL & ", "
				end if
				strCL = strCL & strLastBaseGen
			End If
		
		End If
 
		regPat.Pattern = "^Grain Corn Positioning"
		if regPat.Test(strChart) Then
		
			strRes = strRes & arrHybrid("Grain_Corn_Hybrids_With_Same_Base_Genetics").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Grain_Corn_Parent_Hybrid").Value
			strRes = strRes & "&NDtab;"
		
			strRes = strRes & arrHybrid("Grain_Corn_Relative_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Relative_Maturity_Range").Value
			strRes = strRes & "&NDtab;"
 
			strBaseGen = ""
			strBaseGen = getSpecialTraits(arrHybrid("Grain_Corn_Hybrids_With_Same_Base_Genetics").Value, strColumnName, "")
			If Len(strBaseGen) > 10 Then
				strBaseGen = "<BaseGen>" & strBaseGen & "</BaseGen>"
			End If			
			strRes = strRes & strBaseGen
			strRes = strRes & "&NDtab;"
			
			strRes = strRes & arrHybrid("Grain_Corn_GLS_Heavy_Pressure").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Goss_Wilt_Rating").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Planting_Date_Early").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Planting_Date_Early").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Planting_Date_Early").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
		
			strTemp = ""
			if arrHybrid("Grain_Corn_Planting_Date_Late").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Planting_Date_Late").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Planting_Date_Late").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Crop_Rotation_Continuous_Corn").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Crop_Rotation_Continuous_Corn").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Crop_Rotation_Continuous_Corn").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Crop_Rotation_Corn_Soybean").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Crop_Rotation_Corn_Soybean").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Crop_Rotation_Corn_Soybean").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Conventional_Tillage").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Conventional_Tillage").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Conventional_Tillage").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_No_Till_Tillage").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_No_Till_Tillage").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_No_Till_Tillage").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Full_Irrigation").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Full_Irrigation").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Full_Irrigation").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Limited_Irrigation").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Limited_Irrigation").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Limited_Irrigation").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Dryland_Ecofallow_Irrigation").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Dryland_Ecofallow_Irrigation").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Dryland_Ecofallow_Irrigation").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Marginal_Soil_Fertility").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Marginal_Soil_Fertility").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Marginal_Soil_Fertility").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Poorly_Drained_Soil").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Poorly_Drained_Soil").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Poorly_Drained_Soil").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Light_Sandy_Soil").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Light_Sandy_Soil").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Light_Sandy_Soil").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_High_pH").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Delayed_Harvest").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Delayed_Harvest").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Delayed_Harvest").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Plant_Population_15000_19000").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_15000_19000").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_15000_19000").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Plant_Population_20000_24000").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_20000_24000").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_20000_24000").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Plant_Population_25000_29000").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_25000_29000").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_25000_29000").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Plant_Population_30000_34000").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_30000_34000").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_30000_34000").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Grain_Corn_Plant_Population_34000").Value = "Highly Recommended" Then
				strTemp = "HR"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_34000").Value = "Recommended" Then
				strTemp = "R"
			End If
			if arrHybrid("Grain_Corn_Plant_Population_34000").Value = "Not Recommended" Then
				strTemp = "NR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
		End If
 
		regPat.Pattern = "^Silage Corn Characteristics"
		if regPat.Test(strChart) Then
 
			strRes = strRes & arrHybrid("Silage_Corn_Hybrids_with_Same_Base_Genetics").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Parent_Hybrid").Value
			strRes = strRes & "&NDtab;"
 
			strBaseGen = ""
			strBaseGen = getSpecialTraits(arrHybrid("Silage_Corn_Hybrids_with_Same_Base_Genetics").Value, strColumnName, "")
			If Len(strBaseGen) > 10 Then
				strBaseGen = "<BaseGen>" & strBaseGen & "</BaseGen>"
			End If
			
			strRes = strRes & strBaseGen
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Relative_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Relative_Maturity_Range").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Forage_Yield").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Root_Strength").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Drought_Tolerance").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Silage_Corn_Ear_Type").Value = "Fixed" Then
				strTemp = "FIXED"
			End If
			if arrHybrid("Silage_Corn_Ear_Type").Value = "Flexible" Then
				strTemp = "FLEX"
			End If
			if arrHybrid("Silage_Corn_Ear_Type").Value = "Semi-flexible" Then
				strTemp = "SEMI"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Silage_Corn_Final_Population_High").Value = "X" Then
				If Not strTemp = "" Then
					strTemp = strTemp & ", H"
				Else
					strTemp = "H"
				End If
			End If
			if arrHybrid("Silage_Corn_Final_Population_Mod_High").Value = "X" Then
				If Not strTemp = "" Then
					strTemp = strTemp & ", MH"
				Else
					strTemp = "MH"
				End If
			End If
			if arrHybrid("Silage_Corn_Final_Population_Mod_Low").Value = "X" Then
				If Not strTemp = "" Then
					strTemp = strTemp & ", ML"
				Else
					strTemp = "ML"
				End If
			End If
			if arrHybrid("Silage_Corn_Final_Population_Medium").Value = "X" Then
				If Not strTemp = "" Then
					strTemp = strTemp & ", M"
				Else
					strTemp = "M"
				End If
			End If
			if arrHybrid("Silage_Corn_Final_Population_Low").Value = "X" Then
				If Not strTemp = "" Then
					strTemp = strTemp & ", L"
				Else
					strTemp = "L"
				End If
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Silage_Corn_Kernel_Texture").Value = "Hard" Then
				strTemp = "H"
			End If
			if arrHybrid("Silage_Corn_Kernel_Texture").Value = "Moderatley Hard" Then
				strTemp = "MH"
			End If
			if arrHybrid("Silage_Corn_Kernel_Texture").Value = "Moderate" Then
				strTemp = "M"
			End If
			if arrHybrid("Silage_Corn_Kernel_Texture").Value = "Soft" Then
				strTemp = "S"
			End If
			if arrHybrid("Silage_Corn_Kernel_Texture").Value = "Moderatley Soft" Then
				strTemp = "MS"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Silage_Corn_NFC_Rating").Value
			if strTemp = "Not Rated" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Silage_Corn_WP_Digestibility").Value
			if strTemp = "Not Rated" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Silage_Corn_NDF_Digestibility").Value
			if strTemp = "Not Rated" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Silage_Corn_Digestible_Dry_Matter").Value
			if strTemp = "Not Rated" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Silage_Corn_Dairy_Type").Value
			if strTemp = "Not Rated" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Silage_Corn_Beef_Type").Value
			if strTemp = "Not Applicable" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
			
		End If
 
		regPat.Pattern = "Sorghum Characteristics"
		if regPat.Test(strChart) Then
		
			strRes = strRes & arrHybrid("Sorghum_Hybrid_Number").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Sorghum_Relative_Maturity").Value = "Early" Then
				strTemp = "E"
			End If
			if arrHybrid("Sorghum_Relative_Maturity").Value = "Medium-Early" Or arrHybrid("Sorghum_Relative_Maturity").Value = "Medium/Early" Then
				strTemp = "ME"
			End If
			if arrHybrid("Sorghum_Relative_Maturity").Value = "Medium" Then
				strTemp = "M"
			End If
			if arrHybrid("Sorghum_Relative_Maturity").Value = "Medium-Late" Or arrHybrid("Sorghum_Relative_Maturity").Value = "Medium/Late" Then
				strTemp = "ML"
			End If
			if arrHybrid("Sorghum_Relative_Maturity").Value = "Late" Then
				strTemp = "L"
			End If
			'Overriding the Abbreviation - REMOVE to fallback
			strTemp = arrHybrid("Sorghum_Relative_Maturity").Value
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Days_to_Midbloom").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Yield_Dryland").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Yield_Irrigated").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Sorghum_Plant_Height").Value = "Short" Then
				strTemp = "S"
			End If
			if arrHybrid("Sorghum_Plant_Height").Value = "Medium-Short" Or arrHybrid("Sorghum_Plant_Height").Value = "Medium/Short" Then
				strTemp = "MS"
			End If
			if arrHybrid("Sorghum_Plant_Height").Value = "Medium" Then
				strTemp = "M"
			End If
			if arrHybrid("Sorghum_Plant_Height").Value = "Medium-Tall" Or arrHybrid("Sorghum_Plant_Height").Value = "Medium/Tall" Then
				strTemp = "MT"
			End If
			if arrHybrid("Sorghum_Plant_Height").Value = "Tall" Then
				strTemp = "T"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Grain_Color").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Standability").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Sorghum_Head_Type").Value = "Open" Then
				strTemp = "O"
			End If
			if arrHybrid("Sorghum_Head_Type").Value = "Semi-Open" Then
				strTemp = "SO"
			End If
			if arrHybrid("Sorghum_Head_Type").Value = "Semi" Then
				strTemp = "S"
			End If
			if arrHybrid("Sorghum_Head_Type").Value = "Semi-Compact" Then
				strTemp = "SC"
			End If
			if arrHybrid("Sorghum_Head_Type").Value = "Compact" Then
				strTemp = "C"
			End If
			'Overriding Abbreviation - remove below line to fallback
			strTemp = arrHybrid("Sorghum_Head_Type").Value
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Head_Exsertion").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Uniformity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sorghum_Approximate_Seeds_Per_Pound").Value
			strRes = strRes & "&NDtab;"
 
		End If
 
		regPat.Pattern = "^Soybean Characteristics"
		if regPat.Test(strChart) Then
			
			strRes = strRes & arrHybrid("Soybean_Variety_Number").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Relative_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			'strBaseGen = getSpecialTraits(arrHybrid("Soybean_Variety_Number").Value, strColumnName, "Soybean_Soybean_Cyst_Nematode_Logo")
			'If Len(strBaseGen) > 10 Then
				'strBaseGen = "<BaseGen>" & strBaseGen & "</BaseGen>"
			'End If
			'strRes = strRes & strBaseGen
			'strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Soybean_Soybean_Cyst_Nematode_Susceptible").Value = "X" Then
				strTemp = strTemp & "S"
			End If
			if arrHybrid("Soybean_Soybean_Cyst_Nematode_Resistant").Value = "X" Then
				strTemp = strTemp & "R"
			End If
			if arrHybrid("Soybean_Soybean_Cyst_Nematode_Restistant3").Value = "X" Then
				strTemp = strTemp & "R3"
			End If
			if arrHybrid("Soybean_Soybean_Cyst_Nematode_ModResistant").Value = "X" Then
				strTemp = strTemp & "MR"
			End If
			if arrHybrid("Soybean_Soybean_Cyst_Nematode_ModResistant3").Value = "X" Then
				strTemp = strTemp & "MR3"
			End If
			if arrHybrid("Soybean_Soybean_Cyst_Nematode_ModResistant14").Value = "X" Then
				strTemp = strTemp & "MR14"
			End If
			if arrHybrid("Soybean_Soybean_Cyst_Nematode_Resistant14").Value = "X" Then
				strTemp = strTemp & "R14"
			End If			
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
			
			strTemp = ""
			if arrHybrid("Soybean_Relative_Plant_Height").Value = "Short" Then
				strTemp = "S"
			End If
			if arrHybrid("Soybean_Relative_Plant_Height").Value = "Medium-Short" Or arrHybrid("Soybean_Relative_Plant_Height").Value = "Medium/Short" Then
				strTemp = "MS"
			End If
			if arrHybrid("Soybean_Relative_Plant_Height").Value = "Medium" Then
				strTemp = "M"
			End If
			if arrHybrid("Soybean_Relative_Plant_Height").Value = "Medium-Tall" Or arrHybrid("Soybean_Relative_Plant_Height").Value = "Medium/Tall" Then
				strTemp = "MT"
			End If
			if arrHybrid("Soybean_Relative_Plant_Height").Value = "Tall" Then
				strTemp = "T"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			if arrHybrid("Soybean_Canopy_Type").Value = "Bushy" Then
				strTemp = "Bushy"
			End If
			if arrHybrid("Soybean_Canopy_Type").Value = "Medium Bushy" Then
				strTemp = "Med-Bush"
			End If
			if arrHybrid("Soybean_Canopy_Type").Value = "Medium" Then
				strTemp = "Medium"
			End If
			if arrHybrid("Soybean_Canopy_Type").Value = "Medium Thin" Then
				strTemp = "Med-Thin"
			End If
			if arrHybrid("Soybean_Canopy_Type").Value = "Thin" Then
				strTemp = "Thin"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = arrHybrid("Soybean_Hilum_Color").Value
			if arrHybrid("Soybean_Hilum_Color").Value = "Tan" Then
				strTemp = "T"
			End If
			if arrHybrid("Soybean_Hilum_Color").Value = "Black" Then
				strTemp = "BL"
			End If
			if arrHybrid("Soybean_Hilum_Color").Value = "Gray/Slate" Then
				strTemp = "G/S"
			End If
			if arrHybrid("Soybean_Hilum_Color").Value = "Slate" Then
				strTemp = "S"
			End If
			if arrHybrid("Soybean_Hilum_Color").Value = "Yellow" Then
				strTemp = "Y"
			End If
			if arrHybrid("Soybean_Hilum_Color").Value = "Imperfect Black" Then
				strTemp = "IB"
			End If
			if arrHybrid("Soybean_Hilum_Color").Value = "Buff" Then
				strTemp = "BF"
			End If
			if arrHybrid("Soybean_Hilum_Color").Value = "Brown" Then
				strTemp = "BR"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = arrHybrid("Soybean_Pubescence_Color").Value
			if arrHybrid("Soybean_Pubescence_Color").Value = "Tawny" Then
				strTemp = "T"
			End If
			if arrHybrid("Soybean_Pubescence_Color").Value = "Light Tawny" Then
				strTemp = "Lt.T"
			End If
			if arrHybrid("Soybean_Pubescence_Color").Value = "Gray" Then
				strTemp = "G"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Emergence").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Lodging_Resistance").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Shatter_Resistance").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Adaptation_to_No_Till").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Adaptation_to_Narrow_Rows").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Adaptation_to_Wide_Rows").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Phytophthora_Race_Resistance").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Soybean_Phytophthora_Field_Tolerance").Value
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Soybean_Iron_Chlorosis_Score").Value
			if strTemp = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Soybean_Brown_Stem_Rot").Value
			if strTemp = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Soybean_White_Mold").Value
			if strTemp = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Soybean_Sudden_Death_Syndrome").Value
			if strTemp = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Soybean_Approximate_Oil_at_13").Value
			if strTemp = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strTemp = ""
			strTemp = arrHybrid("Soybean_Approximate_Protein_at_13").Value
			if strTemp = "Not Available" Then
				strTemp = "-"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
		End If
 
		regPat.Pattern = "^Sunflower Characteristics"
		if regPat.Test(strChart) Then
 
			strRes = strRes & arrHybrid("Sunflower_Hybrid_Number").Value
			strRes = strRes & "&NDtab;"
			
			strTemp = ""
			if arrHybrid("Sunflower_DM").Value = "X" Then
				strTemp = "DM"
			End If
			if arrHybrid("Sunflower_CLEARFIELD").Value = "X" Then
				strTemp = "CL"
			End If
			strRes = strRes & strTemp
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Days_to_Flowering").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Days_to_Physiological_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Seedling_Vigor").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Stalk_Quality").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Root_Quality").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Plant_Height").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Oil_Content_10_H2O").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Test_Weight").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Uniformity_at_Flowering").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Self_Compatibility").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Premature_Ripening").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Relative_Drydown_for_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Oilseed_crush_NuSun_Market").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Dehullin_Market").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Bird_Food_Market").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Confection_Market").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Sunflower_Oilseed_crush_Omega_9_Oils_Market").Value
			strRes = strRes & "&NDtab;"
 
		End If
		
		regPat.Pattern = "^Supercede Characteristics"
		if regPat.Test(strChart) Then
 
			'strRes = strRes & arrHybrid("xxx").Value
			'strRes = strRes & "&NDtab;"
 
		End If
    
		regPat.Pattern = "^Grain Corn Herbicide Management"
		if regPat.Test(strChart) Then
 
			strRes = strRes & arrHybrid("Grain_Corn_Relative_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Hybrids_with_Same_Base_Genetics").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Herb_Mgmt_Sulfonylureas_Steadfast").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Herb_Mgmt_Growth_Regulators_Clarity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Herb_Mgmt_Growth_Regulators_Distinct").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Herb_Mgmt_Pigment_Inhibitors_Balance_Pro").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Grain_Corn_Herb_Mgmt_Pigment_Inhibitors_Callisto").Value
			strRes = strRes & "&NDtab;"
 
		End If
 
		regPat.Pattern = "^Silage Corn Herbicide Management"
		if regPat.Test(strChart) Then
 
			strRes = strRes & arrHybrid("Silage_Corn_Relative_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Hybrids_with_Same_Base_Genetics").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Herb_Mgmt_Sulfonylureas_Steadfast").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Herb_Mgmt_Growth_Regulators_Clarity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Herb_Mgmt_Growth_Regulators_Distinct").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Herb_Mgmt_Pigment_Inhibitors_Balance_Pro").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Silage_Corn_Herb_Mgmt_Pigment_Inhibitors_Callisto").Value
			strRes = strRes & "&NDtab;"
 
		End If
 
		regPat.Pattern = "^Supercede Herbicide Management"
		if regPat.Test(strChart) Then
 
			strRes = strRes & arrHybrid("Supercede_Relative_Maturity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Supercede_Hybrids_with_Same_Base_Genetics").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Supercede_Herb_Mgmt_Sulfonylureas_Steadfast").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Supercede_Herb_Mgmt_Growth_Regulators_Clarity").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Supercede_Herb_Mgmt_Growth_Regulators_Distinct").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Supercede_Herb_Mgmt_Pigment_Inhibitors_Balance_Pro").Value
			strRes = strRes & "&NDtab;"
 
			strRes = strRes & arrHybrid("Supercede_Herb_Mgmt_Pigment_Inhibitors_Callisto").Value
			strRes = strRes & "&NDtab;"
 
		End If
 
		'Move to Next Row
		arrHybrid.MoveNext
 
		regPat.Pattern = "^Grain Corn Conversion"
		if Not regPat.Test(strChart) Then
 
			strRes = strRes & "</" & strTag
			if kCnt Mod 2 = 0 Then
				strRes = strRes & "_On"
			Else
				strRes = strRes & "_Off"
			End If
			strRes = strRes & ">"
 
			kCnt = kCnt + 1
 
			'Add a new page
			if kCnt Mod nPageSize = 0 Then
				
				If Not IsNull(logFile) Then
					logFile.WriteLine "Breathe2 pageNum = " & pageNum & ", nPageNum = " & nPageNum & ", pageSize = " & pageSize & ", nPageSize = " & nPageSize & ", kCnt = " & kCnt
				End If
				
				if pageNum = nPageNum And Not nPageNum = -1 Then
 
					If Not IsNull(logFile) Then
						logFile.WriteLine ""
						logFile.WriteLine "OUTPUT2 page " & nPageNum
						logFile.WriteLine strRes
						logFile.Close
					End If
					
					'Close the Legal SQL Recordset
					if arrHybrid.State = adStateOpen then
						arrHybrid.Close
					end If
 
					'Close the SQL Connection completely
					If Cnxn.State = adStateOpen then
						Cnxn.Close
					End if
					
					'Return from the function
					GetFmtTables = strRes
					Exit Function
				Else
					'Reset if requested only for a Specific page
					If Not nPageNum = -1 Then
						strRes = ""
					End If
				End if
				pageNum = pageNum + 1
			End If
		End If
	Loop
	'END of all Hybrids
 
	'Incase of Trait Conversion Chart, update the Master String  with last parent row
	regPat.Pattern = "^Grain Corn Conversion"
	if regPat.Test(strChart) Then
	
		If Not IsNull(logFile) Then
			logFile.WriteLine "GC Conversion Chart - found last parent hybrid"
		End If
 
		If Not IsEmpty(strLastParent) And Not strLastParent = "" Then
			strRes = "<" & strTag
			if kCnt Mod 2 = 0 Then
				strRes = strRes & "_On"
			Else
				strRes = strRes & "_Off"
			End If
			strRes = strRes & ">"
			
			strBaseGen = "&NDtab;" & _ 
						strLastParent & "&NDtab;" & _
						strRM & "&NDtab;" & _
						strLastGenFam & "&NDtab;" & _
						strConventional & "&NDtab;" & _
						strHXX_RR_LL & "&NDtab;" & _
						strHXX_LL & "&NDtab;" & _
						strHXI_RR_LL & "&NDtab;" & _
						strHXI_LL & "&NDtab;" & _
						strENP & "&NDtab;" & _
						strYGVT & "&NDtab;" & _
						strYGP_RR & "&NDtab;" & _
						strYGP & "&NDtab;" & _
						strRR & "&NDtab;" & _
						strLL & "&NDtab;" & _
						strCL 
 
			strRes = strRes & strBaseGen
			strRes = strRes & "</" & strTag
			if kCnt Mod 2 = 0 Then
				strRes = strRes & "_On"
			Else
				strRes = strRes & "_Off"
			End If
			strRes = strRes & ">"
 
			kCnt = kCnt + 1
 
			'Add a new page
			if kCnt Mod nPageSize = 0 Then
				
				If Not IsNull(logFile) Then
					logFile.WriteLine ""
					logFile.WriteLine "Breathe3 pageNum = " & pageNum & ", nPageNum = " & nPageNum & ", pageSize = " & pageSize & ", nPageSize = " & nPageSize & ", kCnt = " & kCnt
					logFile.WriteLine ""
				End If
				pageNum = pageNum + 1
			End If
 
			'Add the Final row
			If convCount = 0 Then
				ReDim Preserve arrConvRows(convCount + 1)
			End If
			arrConvRows(convCount) = strRM & ":" & strRes
			
		End If
	End If
	
	If Not IsNull(logFile) Then
		logFile.WriteLine ""
	End If
	
	if pageNum < nPageNum Then
		strRes = ""
		If Not IsNull(logFile) Then
			logFile.WriteLine "Output was truncated because PAGENUM requested (" & nPageNum & ") is out of bound (" & pageNum & ")"
		End If
	Else
		If Not IsNull(logFile) Then
			logFile.WriteLine "OUTPUT4 page " & nPageNum & " of " & pageNum & " pages :: "
		End If
		
		regPat.Pattern = "^Grain Corn Conversion"
		if regPat.Test(strChart) Then
			Dim arrStr
			if convCount = 0 Then
				arrStr = "make_thing(""" & arrConvRows(0) & """)"
				arrStr = "sortedArr = Array(" & arrStr & ")"
			Else
				arrStr = Join(arrConvRows, """), make_thing(""")
				arrStr = "make_thing(""" & arrStr & """)"
				arrStr = "sortedArr = Array(" & arrStr & ")"
			End If
			
			'MsgBox(arrStr)
			Dim sortedArr
			'Sample test
			'sortedArr = Array(make_thing("4:My Str"),make_thing("1:First thing"),make_thing("9:Nice one"),make_thing("2:second one"),make_thing("7:lucky seven"))
			Execute(arrStr)
 
			dim sort
			set sort = new QSort
			set sort.Compare = GetRef("cmp_thing")
			sort.Sort sortedArr
 
			dim i, index
			Dim strFinale, nStart, nEnd
			i = 0
			index = 0
			nStart = 0
			nEnd = UBound(sortedArr)
			
			'GC Conversion - Calculate page content here
			if (nPageNum-1)*nPageSize < nEnd Then
				nStart = (nPageNum-1)*nPageSize + 1
			End If
			
			if (nPageNum)*nPageSize <= nEnd Then
				nEnd = nPageNum*nPageSize
			End If
			
			If Not IsNull(logFile) Then
				logFile.WriteLine "Start - " & nStart & ", End - " & nEnd
			End If
 
			strFinale = ""
			for index = nStart to nEnd
				Dim sVal
				sVal = Split(sortedArr(index).val, ":")(1)
				strFinale = strFinale & sVal
			next
			
			strRes = strFinale
		End If
	End If
	
	If Not IsNull(logFile) Then
		logFile.WriteLine ""
		logFile.WriteLine "__FINAL_OUTPUT__"
		logFile.WriteLine strRes
		logFile.WriteLine ""
		logFile.Close
	End If
	
	'Close the Legal SQL Recordset
	if arrHybrid.State = adStateOpen then
		arrHybrid.Close
	end If
    
 
	'Close the SQL Connection completely
	If Cnxn.State = adStateOpen then
        Cnxn.Close
	End if
	
	'Return from the function
	GetFmtTables = strRes
End Function
ASKER CERTIFIED SOLUTION
Robberbaron (robr)

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros