|
Very quickly, I can see at least one major flaw in your code, where you've got a resource leak. You're not disposing of your graphics object when you're done with it. When you create a Graphics object, you Dispose it. The result we be the eventual exhaustion of the Windows handle pool. You'll start to get some very strange behavior and error messages, system-wide, when this happens.
When you get the final coordinates of the line being drawn, create a graphics object on the bitmap image you're using as a background, draw the line, dispose of the graphics object, then just set the controls background to the new background image.
|
|
|
|
|
Hello,
I have the following:
A double varialble for ex. 12.5
When i want to make a string of the variable id do the following system.convert.tostring (variable)
The result is indead a string but in the following format 12,5 when i insert that to my SQL 2005 server the SQL makes 125 into the database isntead of 12.5.
When i manualy insert a 12.5 into the SQL there is no problem so 12.5 is in the database.
So i think i have a converison problem .
I dont want to change the regional setting of the pc because when changing those other programs will not work like they should.
So i look for a solution to change the convert method so i can convert to tring but with a . instead of a , or tell to SQL server 2005 that it has to accept , ans use it as a comma.
Any suggestions are very welcome
Thanks
DCAUB
|
|
|
|
|
DCAUB wrote: When i want to make a string of the variable id do the following system.convert.tostring (variable)
The result is indead a string but in the following format 12,5
The ToString is taking into account your locale. Send the ToString method a CultureInfo object of the locale you want to use in the conversion.
DCAUB wrote: when i insert that to my SQL 2005 server
Then you are attempting it INJECT the value into a SQL string. Don't do that. It will cause you problems as it leaves your application open to SQL Injection Attacks.
DCAUB wrote: So i think i have a converison problem .
No. You have a security problem.
DCAUB wrote: I dont want to change the regional setting of the pc because when changing those other programs will not work like they should.
No need. (1) You can set a locale briefly on methods that accept it. (2) Fiddling about with string conversion won't solve the underlying gaping security hole you have.
DCAUB wrote: So i look for a solution to change the convert method so i can convert to tring but with a . instead of a , or tell to SQL server 2005 that it has to accept , ans use it as a comma.
Pass the value as a double directly to SQL Server. Don't inject it into SQL strings.
For more information on securing youself against SQL Injection Attacks please read SQL Injection Attacks and some tips on how to prevent them[^]
|
|
|
|
|
Hello,
Can you give me a small example please.
I have the following
Total as double = 12.5
What i do is :
Sqlstring = "Insert Into test (total) Values ('" + system.convert.tostring (total) + "')"
When checking the sql string there is Insert Into test (total) Values ('12,5') there it is wrong.
After that i execute the above SQL statement
Thanks for helping me out.
Dcaub
|
|
|
|
|
DCAUB wrote: Can you give me a small example please.
I refuse to knowing give examples that will blow security holes in your application.
Read the article I linked to. That will show you how to do it properly that does not require you to convert anything, and is secure.
|
|
|
|
|
Hello,
how can i easily send a string over the internet to another pc, only to know that IP Adress?
I know it's possible with Winsock or Net.Sockets ...
but i am really really new in this area and i don't know how to do that... so it would be great if somebody has a really easy example for me....
I want to do it if possible with a timer, so i have a server application and a client application, the server app sends the string and the client application gets the string, is it possible then to let the client send informations to the server too?
Thank you
|
|
|
|
|
This is done using Winsock (sockets). There are examples all over the 'Net. "Simple" is a matter of understanding. What I would call "simple" is probably not what you would call it.
softwarejaeger wrote: I want to do it if possible with a timer,
Is there something you don't understand about a timer??
<blockquote class="FQ"><div class="FQA">softwarejaeger wrote:</div>the server app sends the string and the client application gets the string, is it possible then to let the client send informations to the server too?</blockquote>
Of course it is.
"vb.net simple sockets"[^]
|
|
|
|
|
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....
|
|
|
|
|