Re: Help with application
Dear OT79,
Then Pls try this
Change the line in reports form to ,
Code:
TotsalesStr = TotsalesStr & Val(esale(0)) & vbTab & Val(esale(1)) & vbTab & Val(esale(2)) & vbTab & Val(esale(3)) & vbTab & Val(esale(4)) & vbTab & Val(esale(5)) & vbTab & Math.Floor(Val(amt1) / 1000) & " . " & Val(amt1) Mod 1000 & vbTab & Val(esale(6)) & vbTab & Math.Floor(Val(amt2) / 1000) & " . " & Val(amt2) Mod 1000 & vbNewLine
Pls Tell if it works
Pramod S Nair
Re: Help with application
Dear PramodsNair;
Yes that is work now, many thanks to you for all you efforts in helping with this application. One last question, how can I get the user inputted Buy Price and Sale Price to be displayed in decimal also, and only show the Buy Value and Sale Value to two places after the decimal point as it is currently showing three places after the decimal? i.e. £4.50 as opposed to current output 4.500
Many thanks
OT
Re: Help with application
Dear OT79,
Pls Try This
Code:
TotsalesStr = TotsalesStr & Val(esale(0)) & vbTab & Val(esale(1)) & vbTab & Val(esale(2)) & vbTab & Val(esale(3)) & vbTab & Val(esale(4)) & vbTab & Math.Floor(Val(esale(5)) / 1000) & " . " & Val(esale(5)) Mod 1000 & vbTab & Math.Floor(Val(amt1) / 1000) & " . " & Val(amt1) Mod 1000 & vbTab & Math.Floor(Val(esale(6)) / 1000) & " . " & Val(esale(6)) Mod 1000 & vbTab & Math.Floor(Val(amt2) / 1000) & " . " & Val(amt2) Mod 1000 & vbNewLine
Please Post if you have any other doubts
Pramod S Nair
Re: Help with application
Dear Pramodsnair;
That works fantastic now, many - many thanks to you for all your efforts!!!
Just one last thing , I now wish to ditch the old VB6 coding I have used on the first form to create and write to a TXT file. I have used the following:
FileOpen(1, "SalesFile.txt", OpenMode.Append)
PrintLine(1, SalesFile)
FileClose(1)
I wish to recreate this with the VB.NET StreamWriter, but so far I have been unsuccessful in my attempts?
OT
Re: Help with application
Below is a short example...
Code:
Dim MyWriter as New System.IO.StreamWriter("c:\test.txt",True) ' True is append mode
MyWriter.WriteLine("test") 'writes "test" to the end of the "test.txt" file
MyWriter.Close 'closes the writer....
Re: Help with application
Dear OT79,
Please add the following line to the very top of your frmMainMenu form's code section
Now in the btnPurchase_click code i have made the following change
The below given lines in old code have been removed
Code:
FileOpen(1, "TotalSalesFile.txt", OpenMode.Append)
PrintLine(1, TotalSalesFile)
FileClose(1)
so remove them
In their place add the below code
Code:
Dim s As StreamWriter
s = File.AppendText("TotalSalesFile.txt")
s.WriteLine(TotalSalesFile)
s.Close()
That will get you equipped to use .NET code instead of VB 6 code. It was a pleasure helping you. Post if you have any more doubts
Pramod S Nair
Re: Help with application
Dear Pramodsnair,
My last and final question! using the coding below, I have the Buy Price and Sale Val showing the correct decimal format, however the Buy Price and Sale Val are showing the incorrect decimal placing, for instance: Weight(20) * Buy Price(220) is showing a Buy Val of 4.400 as opposed to 44! Looking at it, the current coding is working on the first forms input i.e. 220, which when multiplied by Weight (20) would equal 4400! therefore is there a way to ammend this? So Buy Price and SalePrice are in correct format i.e.2.20 and then the Buy Val and Sale Val are taking into account this decimal places, in-order that it can perofrm calculation and output in simliar format i.e. 44.00.
Thanks
Re: Help with application
oops, meant to say your last coding for TotalsSalesFile, not coding below! The following however does show Buy Price and Sale Price in correct format, however I'm unsure of how this affects everthing!!!
TotsalesStr = TotsalesStr & Val(esale(0)) & vbTab & Val(esale(1)) & vbTab & Val(esale(2)) & vbTab & Val(esale(3)) & vbTab & Val(esale(4)) & vbTab & Math.Floor(Val(esale(5)) / 100) & " . " & Val(esale(5)) Mod 100 & vbTab & Math.Floor(Val(amt1) / 1000) & " . " & Val(amt1) Mod 1000 & vbTab & Math.Floor(Val(esale(6)) / 100) & " . " & Val(esale(6)) Mod 100 & vbTab & Math.Floor(Val(amt2) / 1000) & " . " & Val(amt2) Mod 1000 & vbNewLine
Re: Help with application
Dear OT79,
So to ammend the code like that pls make the report forms Load event's code to reflect the below given changes
add these 3 lines just before the
If esale(4) = "1" Then line of code
Code:
Dim bp, sp
bp = Math.Floor(Val(esale(5)) / 1000) & " . " & Val(esale(5)) Mod 1000
sp = Math.Floor(Val(esale(6)) / 1000) & " . " & Val(esale(6)) Mod 1000
Now change the
amt1 = esale(2) * Val(esale(5)) 'Buy * weight
amt2 = esale(2) * Val(esale(6)) 'sale * weight
lines to the below ones
Code:
amt1 = esale(2) * Val(bp) 'Buy * weight
amt2 = esale(2) * Val(sp) 'sale * weight
Also change the below 2 lines
amt1 = esale(3) * Val(esale(5)) ' buy * qty
amt2 = esale(3) * Val(esale(6)) ' sale * qty
with the below given code
Code:
amt1 = esale(3) * Val(bp) ' buy * qty
amt2 = esale(3) * Val(sp) ' sale * qty
Now change our TotalSalesstr to the below given one
Code:
TotsalesStr = TotsalesStr & Val(esale(0)) & vbTab & Val(esale(1)) & vbTab & Val(esale(2)) & vbTab & Val(esale(3)) & vbTab & Val(esale(4)) & vbTab & bp & vbTab & amt1 & vbTab & sp & vbTab & amt2 & vbNewLine
Hope this is what you meant by the last post. I have added the code for filestream in the post given above
Pramod S Nair
Re: Help with application
Dear Pramodsnair;
WOW, I cannot thank you enough for all your hard work and efforts. Its people like you that make learning VB.NET a pleasure. Many, many thanks again.
p.s. I would like to keep in touch with you if possible? I will not bombard you with questions or ask you to complete apps every two minutes; however having a contact like yourself is invaluable. Would it be possible for you to drop me your email address? If so you could email me at: [email protected].
OT
Re: Help with application
Dear OT79,
It's a pleasure. Thanks for your comments.
BTW : i have send a mail to you from my personal id
Pramod S Nair