|
I'd recommend the following:
- create a local variable based on a Trim() of the txtQuantity.Text
- check length first
- next, check for a false on IsNumeric()
- only then look for certain integer values
HTH limit further bugs
btw, which line are you getting the type mismatch from?
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
my svg article
|
|
|
|
|
Here is a basic structure of my code:
Private Sub cmdConfirm_Click()
With Adodc3.Recordset
Do Until .EOF
.MoveFirst
Call Save(iOrderNo, strCode, strDesc, iQuantity, iFullPrice)
.MoveNext
Loop
End With
Function Save(iOrderNo As Integer, strCode As String, strDesc As String, iQuantity As Integer, iFullPrice As Integer) as boolean
.....validation statements and inserts
If Val(DataGrid2.Columns("Quantity").Value) > RS("Quantity").Value Then
Call BackOrder(strCode, strDesc, iQuantity)
End If
Save = True
Function BackOrder(strCode As String, strDesc As String, iQuantity As Integer) As Boolean
....validation and inserts
BackOrder = True
To step through the code briefly, when the command button is pressed, a save function is called (for each row in the datagrid), which performs the necessary validation and saves to the database, this also calls another function - BackOrder, which enters products in a backorder if necessary. I hope the information given is sufficient, and if not, please let me know. The problem occurs when the project is run, there must be something wrong with the loop as it runs through the first row twice, upon which a bug is thrown, without ever moving onto the next row...why is this - how can i make it run through all the rows? Thank you so much - any help would be greatly appreciated!
|
|
|
|
|
mcm wrote:
Do Until .EOF
.MoveFirst
Call Save(iOrderNo, strCode, strDesc, iQuantity, iFullPrice)
.MoveNext
Loop
This code:- Moves to the first record;
- Saves the record;
- Moves to the next record;
- Goes back to the start of the loop;
- Tries to move to the first record;
- Throws an error because you have a forward-only recordset;
Change the loop to:
Do Until .Eof
' TODO: Get these values from the recordset!
Call Save(iOrderNo, strCode, strDesc, iQuantity, iFullPrice)
.MoveNext
Loop
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
hi,
i want to know whether i can use scrrun.dll in vc++(either in mfc or win32 console).if yes can anyone provide me a sample code for this?if no can u pls explain the reason?
Actually i wanted to use the ReadLine Property of scrrun.dll in vc++ either in mfc or win32 to access a text file.
shankar prasad D.R
|
|
|
|
|
I wrote a Multithread ARCNET-Driver in VC++. It receives Data Packets from the NullStackDriver. My VB6 Application opens an controls the Driver. So far so good.
The VC++ DLL is managed by serval Events (CreateEvent(), SetEvent(); ResetEvent(); WaitForSingleObject()...)
On receiving a Complete DataPacket i would like to send a additional Event ex. EVENT_RX to signalize my VB6 that it can read the Packet from the Queue and prozess it.
How can I make my VB6 Application to react on this EVENT_RX ?
Thanks for any Inputs!
|
|
|
|
|
I used to use the sourcesafe as my source control software in previose version of Visual Studio. What is used now with the .NET for source control?
If it is the Sourcesafe, what version (I found in my MSDN version 6)?
Thanks
Ilan
|
|
|
|
|
Visual Studio.NET can use VSS also. You should use 6.0c (which is the version that came with VS.NET Enterprise) since, if I remember correctly, it had some file types changes that help it work with VS.NET. 6.0c should be in the MSDN disks...
|
|
|
|
|
I have a program that plays multiple WAVS at the same time. What I cant figure out how to do is adjust the volume levels and panning for each individual WAV during playback. The only info Ive found is about changing the master WAV device volume. Can someone shed some light on how I can change the volumes and pans of individual WAV files (all of which are playing through the main WAV device output)?
Thanks!
Emil
|
|
|
|
|
Hello, I have the following problem: A class with a property called MyCollection which is, obviously, a collection. The collection MyCollection contains items of type MyItemCollection:
MyClass
property: MyCollection as CustomCollection
CustomCollection
property: MyItemCollection as SecondCustomCollection
Now, I designed custom editors for both "SecondCustomCollection" and "CustomCollection". They both work perfectly, but... When using the collection editor for MyCollection, I click "Add Item" and a new MyCollection item is created. The next step would be to call the editor for the MyItemCollection by pressing a button. That button should programatically call the editor for the second class... This is where I got stuck... Look:
cd is the MyItemCollection:
Dim tp As Type = cd.GetType ' I get it's type
Dim ac As AttributeCollection = t.GetAttributes(tp) ' I get it's attribs
Dim ed As EditorAttribute = CType(ac(GetType(EditorAttribute)), EditorAttribute) 'I get the editor
If Not ed Is Nothing Then ' found it?
Dim te As TypeEditors.ColumnDefCollectionEditor ' this is the editor type
te = New TypeEditors.ColumnDefCollectionEditor(GetType ColumnDefinition.ColumnDefinitionCollection))
Now, the logical call to edit the value would be:
cd = te.EditValue(context, provider, cd)
to launch the editor with the current object and return the same object with the changes.
The place I got stuck is finding the context and the provider. Here is what I tried:
Dim sv As System.ComponentModel.Design.ServiceContainer = New System.ComponentModel.Design.ServiceContainer()
sv.AddService(GetType(IWindowsFormsEditorService), Me)
te.EditValue(cd.GetType, sv, cd)
But it does not work... I get an error at AddService first of all...
So, my question is how can I get the IServiceProvider and the ITypeDescriptorContext required to programatically call my custom editor?
Any help would be appreciated!
Thank you,
Best Regards,
Iulian
|
|
|
|
|
i have performed validation and populated a datagrid via a command button and using a "pseudo" (temporary) table called OrderDetails2. Now I wish to save the details to the proper table (ie OrderDetails), as every row in the datagrid as to be looped through to achieve this, I am using this code:
Dim iRowCount As Integer
'Dim row As Integer
iRowCount = Adodc3.Recordset.RecordCount
For DataGrid2.row = 0 To iRowCount
Call Save
Next row
the code in the save function is:
Dim iOrderNumber As Integer
iOrderNumber = RS.Columns("OrderNo")
Dim strProductCode As String
strProductCode = RS.Columns("ProductCode")
Dim strProductDesc As String
strProductDesc = RS.Columns("ProductDesc")
Dim iProductQty As Integer
iProductQty = RS.Columns("Quantity")
Dim iOrderPrice As Integer
iOrderPrice = RS.Columns("Price")
Dim nSQL As String
'inserting the order into order detail
nSQL = "Insert Into OrderDetail (OrderNo, ProductCode,ProductDesc, Quantity, Price) " & _
" Values (" & iOrderNo & ", '" & strCode & "', '" & strDesc & "', " & iQuantity & ", " & iFullPrice & ")"
Set RS = Conn.Execute(nSQL)
however, when run, a compile error is thrown "variable required - can't assign to this expression" (referring to the datagrid.row)
what can i do to fix this or is there any different way to can achieve the same functionality? Thanking you!
|
|
|
|
|
Set RS = Conn.Execute(nSQL)
I think the above statement is the problem ..
you execute a statement that inserts data in a table and does not return a recordset ..
try using :
Conn.Execute(nSQL)
|
|
|
|
|
similiar to the manner in which you can have a click/LostFocus/GotFocus etc event with textboxes, is there anyway you can have a "tab event" in a specific column of a datagrid? (ie when tabbed across, an action happens in another column)? Thanking you!
|
|
|
|
|
i need to scroll using my middle button using a mouse in a combo box,but i'am unable to do so.please can any one find a solution.
|
|
|
|
|
|
|
Ok, you need to use the API function "SendMessage" (i.e. SendMessageA). I suggest you download the API Guide (Do a search on API Guide on the Internet).
The Scrollbar works by sending the WM_VSCROLL message. Now, you'll have to SubClass the Window you want to handle the Wheel Mouse on. You can do this by intercepting the WM_MOUSEWHELL Message. Again, all this is contained in the API Guide. If you need an example of SubClassing, I can help but I don't have a lot of time to explain it. Also, Subclassing is 100 times easier to do in .NET than VB6.
After you have the WM_MOUSEWHEEL intercepted, just pass the message for it to scroll Up or Down by passing a "0" or "1" to the LParam of the SendMessage (it's either that or the WParam, can't remember off the top of my head).
Call SendMessage(lstBoxHandle, WM_VSCROLL, 1, 0)
Call SendMessage(lstBoxHandle, WM_VSCROLL, 0, 0)
Not all those who are lost are looking to be found. But of those who are lost and those who are found, all are looking for something higher than themselves.
|
|
|
|
|
The function of my form is to generate an order. i am doing this by populating several rows of a datagrid. I have little experience with datagrids and i wish to save the contents of the datagrid, having gone through several validations (eg ensure every cell has been filled out, is there enough quantity in stock etc). i am wondering how to loop through each row of the datagrid, first to validate and then to save each row to the database? is it something like:
for row 1 to ? ( i am unsure of what to put here as the number of rows that will be in the order cannot be predetermined)
perform validation and saving......
next row
how do i declare the rows in the datagrid?
any help would be much appreciated! Thank you!
|
|
|
|
|
Hi,
I have two applications that i have developed, both of these applications need to run in the background as a windows service when ever windows boots up and a user logs in.
Can anyone point in the write direction, i.e. articles or samples, that will help me to achieve this.
Many thanks in advance
Regards
Neil
|
|
|
|
|
|
this is a complicated question and if i dont explain properly, or you need more info, please let me know..any help would be greatly appreciated!
at present, i have bound my datagrid to a "temporary" table (OrderDetails2) in the database, which is only being used for the purposes of the datagrid. instead i wish to bind the datagrid to an array and save the contents of the datagrid later, based on this array. the way the form is working right now is that Textboxes for ProductCode, ProductDesc,txtQuantity and txtFullPrice and when a command button is hit, the OrderDetails2 table is updated and the datagrid is populated correspondingly. Similarly, this happens when the command button is pressed for a second, third time etc. What i wish to happen to store the values in an array, and populate the datagrid this way, and when the command button is hit again , the (dynamic) array is redimmed and the datagrid updates corresponding. how could i go about this or is it even possible?! i have very little experience with arrays ( and indeed datagrids!)
Thanks in advance!
|
|
|
|
|
Hi, i've a problem running an application on a machine which is used by a restricted user: i can't write the registry!!!!
I tried running this prog whith runas (from a dos shell) and it works...so i thought "well, i can write a program which run my application with admin privileges ". I surfed the net but the only things i found are info about this api "logonasuser"...i've made some tests but with no results.
Anyone had the same problem and knows how to resolve it? pls, i'm very short in time!!!
Bye
|
|
|
|
|
Web site: http://test.labdotnet.com/GenuineChannels/GenuineChannels.html
Genuine Channels implement bidirectional TCP channels (for .NET Remoting infrastructure) that solve the primary problem of native tcp channels and all sequential issues. Also they implement some features that help to build durable, viable and stable client-server solutions.
Brief explanation
Microsoft .NET Framework implementation of TCP channels allows using TCP channel only as a server or client connection. If you want to provide feedback from the server to client, server must connect to the client’s port. This scheme consumes two TCP sockets and is not workable if client is behind NAT or Masquerade server. Also, native implementation closes TCP connection after non-customized period of time.
Genuine Channels use the only connection from the client to the server. There is no problem if client is behind firewall, NAT or Masquerade server. Also, Genuine Channels implement some features to help building durable, viable and stable client-server solution.
Features
Only one TCP connection is used between client and server.
Fully compatible with .NET Remoting infrastructure.
Each connection has queue of messages being sent.
Constraints on the queue are possible. It greatly helps to force reconnection if current connection is too slow.
Automatic client reconnection to the server. Server and Clients does not lose messages during reconnection. It’s very useful if your server must talk to the client.
Full support of sync, async and one-way messages.
Adjustable timeout to wait for reply from the remote host.
Real async processing. You can have any number of threads at a server and at a client that will automatically use the same TCP connection.
Each exception has unique identifier that simplifies centralizing error processing or translating error messages to any language.
Automatic ping to check TCP connection if connection has not been used for (by default) 120 seconds.
Detailed logging system that receives all events and can save even the entire incoming and outcoming TCP streams as well as exceptions, stack traces and object’s guids. You can write your own logger and attach it to the system.
Dmitry Belikov.
|
|
|
|
|
I'd like to know just how much ram is required for a loaded DOMDocument.
I've got some XML documents that are a few meg in size, and I'd just like to get an idea of how much memory is being used when these are loaded?
Is there a way to determine this?
|
|
|
|
|
Private Joe as Array
Dim lookupRows() As DataRowView = overrideView.FindRows(New Object() {"lookup_address"})
Simple prob but I'm having a b**ch figuring it out. lookupRows returns an array. how can i copy the returned array to Joe??
Thanks all
Bill
|
|
|
|
|
The following code should work:
Array.Copy(lookupRows,Joe,lookupRows.Length)
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|