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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim Conn As New ADODB.Connectio n
Conn.Open("Prov ider=SQLOLEDB.1 ;Integrated Security=SSPI;P ersist
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.Tex t) & _
"," & 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(st rSql)
Conn.Close()
Conn = Nothing
End Sub
Private Sub TxtAcc_TextChan ged(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles TxtAcc.TextChan ged
End Sub
Private Sub DTSDate_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles DTSDate.TextCha nged
End Sub
Private Sub DTBDate_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles DTBDate.TextCha nged
End Sub
Private Sub TxtContract_Tex tChanged(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles TxtContract.Tex tChanged
End Sub
Private Sub TxtStrike_TextC hanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtStrike.TextC hanged
End Sub
Private Sub TxtSellV_TextCh anged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtSellV.TextCh anged
End Sub
Private Sub TxtbVal_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtbVal.TextCha nged
End Sub
Private Sub TxtITotal_TextC hanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtITotal.TextC hanged
End Sub
Private Sub TxtPTotal_TextC hanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtPTotal.TextC hanged
End Sub
Private Sub TxtProLoss_Text Changed(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles TxtProLoss.Text Changed
End Sub
Private Sub sSymbol_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles sSymbol.TextCha nged
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim Conn As New ADODB.Connectio n
Conn.Open("Prov ider=SQLOLEDB.1 ;Integrated Security=SSPI;P ersist
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.Tex t) & _
"," & 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(st rSql)
Conn.Close()
Conn = Nothing
End Sub
Private Sub TxtAcc_TextChan ged(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles TxtAcc.TextChan ged
End Sub
Private Sub DTSDate_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles DTSDate.TextCha nged
End Sub
Private Sub DTBDate_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles DTBDate.TextCha nged
End Sub
Private Sub TxtContract_Tex tChanged(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles TxtContract.Tex tChanged
End Sub
Private Sub TxtStrike_TextC hanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtStrike.TextC hanged
End Sub
Private Sub TxtSellV_TextCh anged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtSellV.TextCh anged
End Sub
Private Sub TxtbVal_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtbVal.TextCha nged
End Sub
Private Sub TxtITotal_TextC hanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtITotal.TextC hanged
End Sub
Private Sub TxtPTotal_TextC hanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TxtPTotal.TextC hanged
End Sub
Private Sub TxtProLoss_Text Changed(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles TxtProLoss.Text Changed
End Sub
Private Sub sSymbol_TextCha nged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles sSymbol.TextCha nged
End Sub
End Class
Comment