|
Thanks for the info. I am trying to do it with Mod, but it seems to be rounding the floating point.
e.g. if I put
Remainder = 12.6 Mod 5 then answer is rounding it to 3 and it should be 2.6 according to Microsoft. I always think of it as there are 2 fives in 12.6 which equals to 10, 12.6 - 10 with a remainder of 2.6 left over. Is this a correct assumption? Microsoft has this long calculation to explain this.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaoprmod.asp
Someone posted that there is a difference between how Visual Basic and .net perform the Mod calculation.
I'm still trying to figure out how the mod thing would work within my program.
Let's say there is $14.85 leftover
I want to give back $5, $2, $1, , $0.25, $0.10, and $0.05 in change or bills
So I assume first of all that I would need an If statement to check if the amount is above 5 dollars. i.e.
Private Sub Command1_Click()<br />
<br />
<br />
Dim total As Double<br />
Dim amount As Double<br />
<br />
total = 14.85<br />
If total > 5 Then<br />
picMain.Print total<br />
amount = total Mod 5<br />
picMain.Print amount<br />
End If<br />
<br />
<br />
End Sub
Which in theory should give me a leftover of $4.85, but when I run this it gives me 0. I can't figure out why it's not giving me at least the 4.85 or rounding it to 5
Another thing I am struggling with is what kind of code would be able to tell me how many 5's I have extracted from the 14.85? If I can figure out these two problem, then I can pretty much figure out how to do the rest.
Thanks for all the help
|
|
|
|
|
Hi to ALL,
I need to determine the total no of ports (currently in use and also not active)in the system irrespective of the OS
Can any one suggest me how to do this...
Your suggestion will be highly appreciated.
Thanks
|
|
|
|
|
You're going to have to be a lot more specific about what you want. Are you talking about TCP/IP ports? Are you talking about port scanning?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Declare the control using the WithEvents modifier, then write a sub that Handles the exposed event.
Snatched from an MSDN example:
Dim WithEvents EClass As New EventClass() ' Declare a WithEvents variable.
' Declare an event handler that handles multiple events.
Sub EClass_EventHandler() Handles Eclass.XEvent
MsgBox("Received Event.")
End Sub
Class EventClass
Public Event XEvent()
Sub RaiseEvents() 'Raises two events handled by EClass_EventHandler.
RaiseEvent XEvent()
End Sub
End Class
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Please help with code. I have an access db with table called transactions, 2 columns Sno and amount. I want to get
the total amount to a label where sno = x
|
|
|
|
|
Why does this sound like homework?
You can retrieve the total using a simple SQL statement:
SELECT SUM(amount) FROM myTable WHERE Sno = 'X'
or something very similar to this. How you get this statement executed on your database is entirely up to you.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have to programing with VB.NET and Excel. I use Microsoft Development Environment 2003 and Excel 2000. But I cannot create a workbook:
Dim xlsApp As Excel.Application
Dim xlsWB As Excel.Workbook
xlsApp = New Excel.Application
xlsWB = xlsApp.Workbooks.Add() <-- error in this line
The error message is:
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred "
and
"Additional information: Old format or invalid type library."
I added the Microsoft Excel 9.0 Object Library (excel9.olb) as a reference and use
Imports Excel.
Anyone give me a suggestion?
Thank you
|
|
|
|
|
It looks like you referenced the Excel 9.0 Object library, but are using the Excel 10 (or better Primary Interop Assemblies). Set the reference to Excel 10.0 instead and see what happens.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm using Microsoft Office 2000. When this error occurs, I installed the Office 2000 SP3, but the problem still exists
|
|
|
|
|
I have a Application that has to start say every night at 9.
But I do not want to use windows scheduled tasks,
Do I have to use a Timer or is there another way.
Your input would be appriciated
|
|
|
|
|
NathanJonker wrote:
I have a Application that has to start say every night at 9.
But I do not want to use windows scheduled tasks
Then your application is going to have to run continuously and perform its task at the time you set. A timer would allow it to wake up periodically to check the time.
NathanJonker wrote:
is there another way
You could also set the application into a loop that checks the time, if it is >= the time you specify it starts the job - when finished it flags it as done for the day. If the job is not running then it Thread.Sleep(x); and loops around again. However, if the application is sleeping it does not respond to the system so if you set x to be too long and shutdown your PC you may get an "application is not responding" error message.
Does this help?
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
|
In addition to what Colin said, when he mentioned that your app has to run continuously, that means that a user has to be logged in and running your app 24x7. Are you sure this is what you want? Or are you considering converting your application to a service?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanx Dave
Yes that sounds good how do you convert your application to a service
|
|
|
|
|
|
I am linking all of the columns of a database table to a dataset, binding the table to a datagrid, and using simple binding to bind individual fields to text boxes. However, in the datagrid, I would like to only display a small subset of the columns in the record so that a user can recognize and select the desired record. I don't see a convenient way to do this. The DataView appears to require display of all of the table's columns. Any suggestions?
|
|
|
|
|
The DEFAULT DataView will generate all columns. Create your own DataView using only the columns you want (why do you think they call it a VIEW?), then Bind the DataGrid to that.
Creating a DataView[^] (.NET Developers Guide) Pay particular attention to the links at the bottom of the page.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You were right. Thanks. It was right under my nose all the time.
|
|
|
|
|
You should charge into dataset ONLY the lines and columns of the database table you really need, in this way it should works fine. To do it you only need to filter them using a SQL query. I mean you shouldn't charge dataset directly from database, you should charge dataset using a SQL query, in this way you'll see into Datagrid only the lines and columns you need.
I hope this help you.
|
|
|
|
|
Using VB.NET and an Access DB
How do I get from text to time that is recognized by .NET?
I am currently using the Masked Edit Control from VB.6 which I added to my toolbox. I have one Masked Edit Control for date, and am able to get the correct date. I have another control for time and no matter what I enter, it comes back as 1/1/2001.
For maskDate: format property is: dddddd, mask property is: ##/##/##
for maskTime: format property is: hh:mm, mask property is: ##:##
Dim dtmTime As Date<br />
Dim dtmDate As Date<br />
<br />
Dim drTime As ds5TimeDate.TimeTblRow<br />
drTime = Ds5TimeDate1.TimeTbl.NewTimeTblRow<br />
<br />
drTime.EventID = txtEventID.Text<br />
dtmDate = maskDate.FormattedText<br />
dtmTime = maskTime.FormattedText<br />
drTime._Date = dtmDate<br />
drTime.Time = dtmTime<br />
<br />
Ds5TimeDate1.TimeTbl.AddTimeTblRow(drTime)
|
|
|
|
|
Are you looking for DateTime.Parse()[^]?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks, Dave,
But that seems to be about taking DateTime and manipulating it to get the string values desired. I want to go the other way, from string to DataTime.
On further investigation, it looks like VB is accepting the user input as LongTime (#10:00:00 AM#). The problem seems to be in updating the data source, the database in Access.
Anyone know how to turn the LongTime into 24-hour clock time?
|
|
|
|
|
numbrel wrote:
But that seems to be about taking DateTime and manipulating it to get the string values desired.
If that were the case, the method would be called .ToString() . DateTime.Parse() takes a string, and optionally, a format provider for some guidance, and returns a .NET DateTime object with the numerical version of the date and time.
If the user is entering date and time seperately, you can combine them and submit the new date/time string to the Parse method:
dtmDate = maskDate.FormattedText
dtmTime = maskTime.FormattedText
Dim myDateTime As DateTime = DateTime.Parse( dtmDate & " " & dtmTime )
The .Parse() method assumes that the full date and time are provided in the current culture, which on default US machines is "mm/dd/yyyy hh:mm:ss". If any information is missing, the default action is to replace the missing information with the current date/time info.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|