|
Hi
Can Anybody tell me how can i update my database by editing data visible from database in DataGrid
shaeron
|
|
|
|
|
|
Hi All,
This is my first question.
I have been in a couple of months developing application using VB.NET Compact Edition. I have a problem.
My form have listbox, textbox and other data bound controls. If I update the data using ExecuteNonQuery(), how do I reflect the change in those data bound controls?
Any help would be appreciated.
Thanks you,
Eko SW
|
|
|
|
|
Hello everybody,
The code below is a VBA code I originally created for a MACRO in excel 2003. My goal is to be able to execute the code below from a VB 2005/VB.NET module/application. In other words, could someone help me out with correcting the syntax errors? I'm quite confident about my excel VBA skills, but I am so stuck on converting this to VB 2005/VB.NETAny help would be so tremendously appreciated. I've tried reseraching what I can do, but unfortunately, I'm completely stuck.
Module ShelfList
Sub calculateAmount()
Dim boAmount As Decimal
Dim boUnit As Integer
Dim shippedAmount As Decimal
Dim shippedUnit As Integer
boAmount = "0.00"
boUnit = 0
shippedAmount = "0.00"
shippedUnit = 0
Dim range1 As Range
range1 = ActiveSheet.Range("A1")
Do While range1.Value <> "Not Filled / On Order"
range1 = range1.Offset(1, 0)
Loop
range1 = range1.Offset(1, 0)
Do While range1.Value <> "Other"
range1 = range1.Offset(0, 17)
boAmount = boAmount + range1.Value
If range1.Value <> "" Then boUnit = boUnit + 1
range1 = range1.Offset(1, -17)
Loop
range1 = range1.Offset(0, 17)
'range1.Value = boAmount
range1 = range1.Offset(1, 0)
Do While range1.Value <> ""
shippedAmount = shippedAmount + range1.Value
If range1.Value <> "" Then shippedUnit = shippedUnit + 1
range1 = range1.Offset(1, 0)
Loop
'range1.Value = shippedAmount
'range1.Select
Sheets.Add()
Dim range2 As Range
range2 = ActiveSheet.Range("A1")
range2.Value = "Back Order Amount"
range2 = range2.Offset(0, 1)
range2.Value = boAmount
range2 = range2.Offset(1, -1)
range2.Value = "Back Order Units"
range2 = range2.Offset(0, 1)
range2.Value = boUnit
range2 = range2.Offset(1, -1)
range2.Value = "Shipped Amount"
range2 = range2.Offset(0, 1)
range2.Value = shippedAmount
range2 = range2.Offset(1, -1)
range2.Value = "Shipped Units"
range2 = range2.Offset(0, 1)
range2.Value = shippedUnit
Columns("A:A").EntireColumn.AutoFit()
Columns("B:B").EntireColumn.AutoFit()
Columns("A:A").Select()
Selection.Font.Bold = True
ActiveSheet.Name = "Totals"
ActiveWorkbook.Save()
End Sub
End Module
|
|
|
|
|
Where are you stuck?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
When I first tried to use the Excel macro code in VB 2005, it was clear that "Range" was not a valid data type therefore the code falls apart after "Dim range1 As Range." I'm just not sure how Excel data is read by VB and I'm not sure how to address the incoming data. In Excel, I use "ActiveSheet" and "Columns" to comb through the data but I am unable to find any information on how to do create an application in VB 2005 that will do something similar.
See underlined sections below as an example.
<br />
Module ShelfList<br />
<br />
Sub calculateAmount()<br />
<br />
Dim boAmount As Decimal<br />
Dim boUnit As Integer<br />
Dim shippedAmount As Decimal<br />
Dim shippedUnit As Integer<br />
<br />
boAmount = "0.00"<br />
boUnit = 0<br />
shippedAmount = "0.00"<br />
shippedUnit = 0<br />
<br />
Dim range1 As Range<br />
range1 = ActiveSheet.Range("A1")<br />
<br />
Do While range1.Value <> "Not Filled / On Order"<br />
range1 = range1.Offset(1, 0)<br />
Loop<br />
<br />
range1 = range1.Offset(1, 0)<br />
<br />
Do While range1.Value <> "Other"<br />
range1 = range1.Offset(0, 17)<br />
boAmount = boAmount + range1.Value<br />
If range1.Value <> "" Then boUnit = boUnit + 1<br />
range1 = range1.Offset(1, -17)<br />
Loop<br />
<br />
range1 = range1.Offset(0, 17)<br />
'range1.Value = boAmount<br />
<br />
range1 = range1.Offset(1, 0)<br />
Do While range1.Value <> ""<br />
shippedAmount = shippedAmount + range1.Value<br />
If range1.Value <> "" Then shippedUnit = shippedUnit + 1<br />
range1 = range1.Offset(1, 0)<br />
Loop<br />
<br />
'range1.Value = shippedAmount<br />
<br />
'range1.Select<br />
<br />
<br />
Sheets.Add()<br />
Dim range2 As Range<br />
range2 = ActiveSheet.Range("A1")<br />
<br />
range2.Value = "Back Order Amount"<br />
range2 = range2.Offset(0, 1)<br />
range2.Value = boAmount<br />
<br />
range2 = range2.Offset(1, -1)<br />
range2.Value = "Back Order Units"<br />
range2 = range2.Offset(0, 1)<br />
range2.Value = boUnit<br />
<br />
range2 = range2.Offset(1, -1)<br />
range2.Value = "Shipped Amount"<br />
range2 = range2.Offset(0, 1)<br />
range2.Value = shippedAmount<br />
<br />
range2 = range2.Offset(1, -1)<br />
range2.Value = "Shipped Units"<br />
range2 = range2.Offset(0, 1)<br />
range2.Value = shippedUnit<br />
<br />
Columns("A:A").EntireColumn.AutoFit()<br />
Columns("B:B").EntireColumn.AutoFit()<br />
Columns("A:A").Select()<br />
Selection.Font.Bold = True<br />
ActiveSheet.Name = "Totals"<br />
ActiveWorkbook.Save()<br />
<br />
End Sub<br />
<br />
End Module<br />
|
|
|
|
|
The Excel object should be referenced in your project. Try looking up MS Office Interop.
|
|
|
|
|
Hello again
I've a textbox where i write the name of a file or a folder to check
to check a foder I've a function and to check a file I've another function
how to distinct if the user write the name of a foder or a file to tell the programe which function to check
thanks in advance
Assaf
|
|
|
|
|
Using just what the user typed in the TextBox, you can't. How about trying BOTH functions, with proper result handling, and seeing which function says the entered name exists?
|
|
|
|
|
each function give a message tell me the result
but i try to avoud having to message box
if there other way please tell me
Assaf
|
|
|
|
|
It's not a matter of a function giving you what you want. It's your logic that's flawed here. Your methods that check for the existance of a folder or file should just return a Boolean. They shouldn't put up a MessageBox at all.
Think about it. You call both functions with the same name. If they both return false, then the entered name doesn't exist as either a file or a folder. If one of them returns true, then I guess you've found out which it is. If they both return true, you've seriously messed up your checking code in one or both of your methods.
|
|
|
|
|
Hello
how i can check if a specific foder exist or not
folder and not a file
Thanks in advance
Assaf
|
|
|
|
|
I get it
directoryInfo
Stupid question i know
Assaf
|
|
|
|
|
Hi!
I have compiled a DLL in C++ (on WinXP) and I need to use it in Visual Basic (actually, in VBA included in Excel).
I have used the following declare command in Excel VBA:
Public Declare Function apSimulator Lib _
"C:\Econoblast++\PricerLibrary.dll" Alias "_Simulator_average_performance@72" _
( ... arguments...) As Double
1) On the machine I have used to build my DLL, everything is OK: VBA correctly calls the DLL (finds its entry point and matches its calling convenctions,etc...).
2) If I change DLL name or extension, for instance from .dll to .dol, if I change path in Declare command, everything is still Ok.
3) When copy my *.xls and *.dll file on onother machine, VBA returns run-time error #48: It Can't find the file.
EVEN THOUGH THE FILE REALLY EXISTS, AND ITS FULLY QUALIFIED PATH IS OK!!
What does it mean?????
Should I "register" my dll? The test of point 2) should mean I don't have to, doesn't it?
On every machine different from the one I used to build the DLL, or at least on the once I tested, VBA returns error 48.
Plz, HELP ME!!!
|
|
|
|
|
I think, but am not sure, when you compile a DLL, the system automatically registers it.
Try unregistering it on my development machine and try VBA again.
Then, register it on the non-development machine and try VBA.
Post the results.
Tim
|
|
|
|
|
Read my next answer. Actually, my dll seems not to be registered (because it has not to be registered).
|
|
|
|
|
Registering the .DLL only works if you've written a COM dll. If not, then you'll get an error message when you try and register it.
Other than that, you're best solution is to NOT include the full path to the .DLL in your code, but just mention the .DLL name. Then, you put the .DLL file you're using in the same folder as your .EXE.
Public Declare Function apSimulator Lib "PricerLibrary.dll" _
Alias "_Simulator_average_performance" (...arguments...) As Double
Did you really called the function in your DLL code "_Simulator_average_performance"??
|
|
|
|
|
Ok, it is not a Com DLL and if I attempt to register it I get and error, indeed. Neither I can unregister it, of course (I tried to, but I get the same error). So "registering DLL" shouldn't be the right way.
I tried to use a relative path, but it doesn't work anyway!!!
What can it be??
Er.. actually my DLL function name is
_Simulator_average_performance@74
(I forgot a "@74" in previous message, but not in the code, of course )
This because I couldn't manage to export the function name "Simulator_average_performance" without those silly decoration imposed by __stdcall... but this is another matter.
My problem seems to be a NONSENSE
Plz, help me in debugging....
|
|
|
|
|
Capitanevs wrote: Er.. actually my DLL function name is
_Simulator_average_performance@74
(I forgot a "@74" in previous message, but not in the code, of course )
The reason why the compiler "decorated" the names is for type safety.
You cannot use the "@74" in the alias name. You can use either the function name (undecorated), or use its oridnal number. To use the ordinal, your declare would look something like this:
Public Declare Function apSimulator Lib "PricerLibrary.dll" _
Alias "#74" ( ... arguments...) As Double
|
|
|
|
|
Are you sure?
I have used like I wrote and I used to work (until it stopped, at least... )
I mean, if I use dependencies viewer to inspect my dll a function named
_FunctionName@74 appears in the function list. So I expect "_FunctionName@74" to be the effective name whom the DLL function is seen with bt an external caller.
What is an ordinal?
|
|
|
|
|
The ordinal is a number used to reference the function name if you don't have the name, or can't use it. In "Depends", it's listed right next to the function name.
|
|
|
|
|
|
Capitanevs wrote: 2) My DLL doesn't depend dynamically on anything. I had to use an external precompiled library, but It should be embedded in the code, shouldn't it?
If it's statically linked, yes. If not (default), no. The libraries are seperate.
Which version of C++ did you use to compile this .DLL?? Are the correct version of the runtime libraries installed on the target machine??
|
|
|
|
|
I used Visual C++ 2008 Express Edition.
What do you mean with "runtime libraries" ?
Why a DLL built in C++ needs runtime libraries? This happens with every compiler or only with Microsoft ones?
I inspected dependencies of my DLL and I found two DLL
MSVCP90.dll
MSVCR90.DLL
that I have only on my dev-machine. Do you think this is the point?
I tried to copy them in \system32\ or in \appfolder\, tried to register them (but they probably needn't to), but on the generic-machine my DLL still doesn't work.
Do you think I should post this topic on the VC++ forum?
Finally, we seem to have shown that it is a VC rather than VB matter..
|
|
|
|
|
Capitanevs wrote: What do you mean with "runtime libraries" ?
Why a DLL built in C++ needs runtime libraries? This happens with every compiler or only with Microsoft ones?
This happens with every compiler. Yes, you need the libraries. The compiler doesn't automagically know how what is needed to get code running, nor does it know how all of those function calls you made work, nor does it know what those functions are or what they're return values are supposed to be, ... This is where those libraries come in. Instead of putting all that extra code (you didn't write) into your binary, the compiler puts in "imports", or what your code needs from the outside world in order to get at those functions you're calling.
Capitanevs wrote: I inspected dependencies of my DLL and I found two DLL
MSVCP90.dll
MSVCR90.DLL
that I have only on my dev-machine. Do you think this is the point?
Yep.
<blockquote class="FQ"><div class="FQA">Capitanevs wrote:</div>I tried to copy them in \system32\ or in \appfolder\, tried to register them (but they probably needn't to), but on the generic-machine my DLL still doesn't work.</blockquote>
That's because you can't get away with doing that. Those libraries have dependancies of their own. You have to install the runtime package on the target machine in order to get it to work.
Get it here[^].
|
|
|
|
|