Public Function GetMaxMargin() As Double Dim value As String For Each myRow As DataRow In myDataSet.Tables("EnvironmentVariableTbl").Rows If myRow("Name").Trim() = "MaxMargins" Then value = myRow("Value") Return Double.Parse(value) End If Next MessageBox.Show("Holy BatMouse! Could not find 'MaxMargins'. Returned 0.") Return 0 End Function Public Function GetStartDate() As Date Dim value As String For Each myRow As DataRow In myDataSet.Tables("EnvironmentVariableTbl").Rows If myRow("Name").Trim() = "StartDate" Then value = myRow("Value") Return Date.Parse(value) End If Next MessageBox.Show("Holy BatScreen! Could not find 'StartDate'. Returned 1/1/1.") Return "1/1/1" End Function Public Function GetAsk(symbol As String, targetDate As Date) As Double symbol = symbol.Trim() If (targetDate.DayOfWeek = DayOfWeek.Saturday) Then targetDate = targetDate.AddDays(-1) End If If (targetDate.DayOfWeek = DayOfWeek.Sunday) Then targetDate = targetDate.AddDays(-2) End If DownloadPricesForOneDay(targetDate) If IsAStock(symbol) Then For Each myRow As DataRow In myDataSet.Tables("StockMarketOneDayTbl").Rows If myRow("Ticker").trim() = symbol Then Return myRow("Ask") End If Next Else ' is an option For Each myRow As DataRow In myDataSet.Tables("OptionMarketOneDayTbl").Rows If myRow("Symbol").trim() = symbol Then Return myRow("Ask") End If Next End If MessageBox.Show("Holy Batsandals! Could not find the ask for " + symbol + ". Returned 0.") Return 0 End Function