|
Hi,
I realize not everyone speaks English as a first language, and that can make studying documentation more difficult. And everyone has to start somewhere. So I don't mean to be insulting but you should probably find a text on basic VB/database programming ...
-----------------------------------------------------------------------------------------
'Read datepicker values into strings
strDateStart = dtpStart.Value
strDateEnd = dtpEnd.Value
'Concatenate query string with date values
strSQL = "SELECT * FROM MyTable WHERE [MyDate] BETWEEN #" & strDateStart & "# AND #" & strDateEnd & "#"
'TODO: Add ADO code to execute query
-----------------------------------------------------------------------------------------
|
|
|
|
|
Hi Shah
If you're using Access with ad-hoc queries (meaning you write the e.g. "SELECT * FROM CUSTOMERS" in your code, and the relevant field is a date/time filed to have two options:
1. "SELECT * FROM CUSTOMERS WHERE PAYDATE < #01/02/2005# OR PAYDATE > #01/01/2005"
2. "SELECT * FROM CUSTOMERS WHERE PAYDATE BETWEEN #01/01/2005# AND #01/02/2005#"
option 2 is a better option, use the "BETWEEN" keyword to search your records, it might be that I got the query other way around, but a quick search for BETWEEN in MSDN will will help you with it.
first of all you need to get the date from your datepicker in date format, the same as your Access field e.g. ShortDate:
Dim tmpDate as date
tmpdate = dtpicker.value 'this will hold the date/time value
ctype(format$(tmpdate, "dd/MM/yy")) 'convert it to a format 15/10/04. Note the capital M - it's importand, cause lowarcase m means minute in time
-------OR----------
!! I'm into VB.Net now - can't really remeber if VB 6.0 can do this option !!
Dim tmpDate1 as date
Dim tmpDate2 as date
tmpdate1 = dtpicket1.value.toshortdate
tmpdate2 = dtpicket2.value.toshortdate
then your query:
1. "SELECT * FROM CUSTOMERS WHERE PAYDATE < #" & tmpdate1 & "# OR PAYDATE > #" & tmpdate2 & "#"
2. "SELECT * FROM CUSTOMERS WHERE PAYDATE BETWEEN #" & tmpdate1 & "# AND
#" & tmpdate2 & "#"
Hope this helps and you understands what I mean
Arnooel
|
|
|
|
|
I am currently taking a vb class and I am doing an exercise that involves creating a machine where people insert their money and choose a card value. The machine is suppose to give them back change.
Let's say I insert 7.90 and the item costs 5.00 then the machine would give them a 2 dollar bill 3 quarters 1 dimes and 1 nickel. I am new to programming and for the life of me I can't figure out howto make VB tell howto divide up the change in this manner. It's all just printed to a pic box
Any help would be appreciated.
Thanks
|
|
|
|
|
Most beginning programming and algorithm books have examples that teach how to do this. You basically start with your highest denomination change value ($5 bill maybe?) and go from there. Create a while loop while your accumulated changed is less than total change. Keep adding your current denomination until each unit is greater than your amount left to change...then go to the next lower value. When the loop ends
, you'll have the exact change.
|
|
|
|
|
|
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.
|
|
|
|