G
Guest
In the code below I’m trying to figure out how to dynamically perform math
functions in a form. To start, I would like to subtract
TxtITotal.Text from TxtPTotal.Text and display the results in
TxtProLoss.Text before sending the data to the database. I have no
idea where to begin.
Any help would be greatly appreciated,
Thank you,
Mark
Public Class Form1
Dim StrServer As String = "servername"
Dim strUserName As String = "username"
Dim strPassword As String = "password"
Dim strDB As String = "ABC"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Conn As New ADODB.Connection
Conn.Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;User ID=" & strUserName & _
";password=" & strPassword & ";Initial Catalog=" & strDB &
";Data Source=" & StrServer)
Dim strSql As String
strSql = "INSERT INTO SP_Trading_1 (acct, sSymbol, tDateS, tDateB,
contracts, strike, sValue, bValue, iTotal, pTotal, Pl) VALUES (" & _
CDbl("0" & TxtAcc.Text) & ",'" & sSymbol.Text & "','" &
DTSDate.Text & "','" & DTBDate.Text & "'," & CDbl("0" & TxtContract.Text) & _
"," & CDbl("0" & TxtStrike.Text) & "," & CDbl("0" &
TxtSellV.Text) & "," & CDbl("0" & TxtbVal.Text) & "," & _
CDbl("0" & TxtITotal.Text) & "," & CDbl("0" & TxtPTotal.Text) &
"," & CDbl("0" & TxtProLoss.Text) & ")"
Conn.Execute(strSql)
Conn.Close()
Conn = Nothing
End Sub
Private Sub TxtAcc_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TxtAcc.TextChanged
End Sub
Private Sub DTSDate_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles DTSDate.TextChanged
End Sub
Private Sub DTBDate_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles DTBDate.TextChanged
End Sub
Private Sub TxtContract_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TxtContract.TextChanged
End Sub
Private Sub TxtStrike_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtStrike.TextChanged
End Sub
Private Sub TxtSellV_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtSellV.TextChanged
End Sub
Private Sub TxtbVal_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtbVal.TextChanged
End Sub
Private Sub TxtITotal_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtITotal.TextChanged
End Sub
Private Sub TxtPTotal_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtPTotal.TextChanged
End Sub
Private Sub TxtProLoss_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TxtProLoss.TextChanged
End Sub
Private Sub sSymbol_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles sSymbol.TextChanged
End Sub
End Class
functions in a form. To start, I would like to subtract
TxtITotal.Text from TxtPTotal.Text and display the results in
TxtProLoss.Text before sending the data to the database. I have no
idea where to begin.
Any help would be greatly appreciated,
Thank you,
Mark
Public Class Form1
Dim StrServer As String = "servername"
Dim strUserName As String = "username"
Dim strPassword As String = "password"
Dim strDB As String = "ABC"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Conn As New ADODB.Connection
Conn.Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;User ID=" & strUserName & _
";password=" & strPassword & ";Initial Catalog=" & strDB &
";Data Source=" & StrServer)
Dim strSql As String
strSql = "INSERT INTO SP_Trading_1 (acct, sSymbol, tDateS, tDateB,
contracts, strike, sValue, bValue, iTotal, pTotal, Pl) VALUES (" & _
CDbl("0" & TxtAcc.Text) & ",'" & sSymbol.Text & "','" &
DTSDate.Text & "','" & DTBDate.Text & "'," & CDbl("0" & TxtContract.Text) & _
"," & CDbl("0" & TxtStrike.Text) & "," & CDbl("0" &
TxtSellV.Text) & "," & CDbl("0" & TxtbVal.Text) & "," & _
CDbl("0" & TxtITotal.Text) & "," & CDbl("0" & TxtPTotal.Text) &
"," & CDbl("0" & TxtProLoss.Text) & ")"
Conn.Execute(strSql)
Conn.Close()
Conn = Nothing
End Sub
Private Sub TxtAcc_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TxtAcc.TextChanged
End Sub
Private Sub DTSDate_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles DTSDate.TextChanged
End Sub
Private Sub DTBDate_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles DTBDate.TextChanged
End Sub
Private Sub TxtContract_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TxtContract.TextChanged
End Sub
Private Sub TxtStrike_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtStrike.TextChanged
End Sub
Private Sub TxtSellV_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtSellV.TextChanged
End Sub
Private Sub TxtbVal_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtbVal.TextChanged
End Sub
Private Sub TxtITotal_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtITotal.TextChanged
End Sub
Private Sub TxtPTotal_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtPTotal.TextChanged
End Sub
Private Sub TxtProLoss_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TxtProLoss.TextChanged
End Sub
Private Sub sSymbol_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles sSymbol.TextChanged
End Sub
End Class