|
Hello,
I am facing a problem in key event handler for datagrid textbox cells. The event is fired for all the function key presses except for F2 and F5 keys. Any ideas or pointers are welcome.
Thanks,
Neo
|
|
|
|
|
F2 is reserved by the DataGridView to trigger editing whichever cell is currently selected. Change the DGV's EditMode property if you want to use this key for something else.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks...
But we are using dotnet 1.1. I guess this editmode feature is not available in 1.1... Is there any other alternative to make this work?
|
|
|
|
|
Not as far as I can tell. F2 is still reserved for the DataGrid. Keyboard shortcuts for DataGrid[^].
The keys are being handled by the DataGrid control before they're getting to the grid's TextBox. That's why you can't see them in that handler.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Sir,
can i find out whether the database sqlserver is installed on the machine before making the connection.
Thanks
|
|
|
|
|
On which machine? The local machine you application is running on, or on the remote server you're trying to connect to?
In either case, there's alot that can go wrong, other than not being installed, with trying to connect to an SQL Server, so I fail to see what the advantage of seeing if it's installed gives you.
Sure, it can be installed, but is it running? Is there a network path to the server? Is there a firewall in the way, blocking access? Is the database you're trying to connect to available? ...?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
kindly help in fixing the code below
Dim dprinters As Printer<br />
For Each dprinters In Printers<br />
Printer.Print dprinters.DeviceName; " on "; dprinters.Port<br />
Next dprinters<br />
Dim a As Integer<br />
Dim b As Integer<br />
a = 5<br />
b = 7<br />
Dim s As String<br />
s = "are figures"<br />
Printer.Print a; Spc(1); b; Spc(1); s
when the code was placed in form_load it printed but when moved to the cmdprint_click it did not load.
how can I print from clicking a command button
Also how can I specify the size of the paper I want to use because i want to use a custom paper to print.
Fikunmi Feyijin
Hicad Systems
Nigeria
|
|
|
|
|
The code should work just fine. It doesn't matter which event handler you put it in.
To change the paper size, all you have to do is set the Height and Width propeties of the Printer object:
Printer.Height = paper height in twips
Printer.Width = paper width in twips
where 1" = 1440 twips.
Printer and Printers documentation[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am trying to instantiate a class from an external COM application. After stepping through, it seems as though the instance is being initialized and then immediately terminated for some reason. This also happens when I try to debug the problem using the immediate window from the project that contains the class I am trying to reference.
Here is how I am trying to instaniate the class:
Public moServer As Wrapper.CommConnector
Private WithEvents mwDeviceCommMgr As Wrapper.CommManager
...
Set moServer = New Wrapper.CommConnector
Set mwDeviceCommMgr = moServer.CommGateway
This program throws an error on
Set moServer = New Wrapper.CommConnector because the class terminates immediately.
Here are the initialization and termination methods for Wrapper.CommConnector:
Private Sub Class_Initialize()
Set xCommConnector = New Server.CommConnector
End Sub
Private Sub Class_Terminate()
On Error GoTo Unanticipated_Error
Set goCommConnection = Nothing
Set xCommConnector = Nothing
End Sub
Server is a VB.NET application that is known to be solid code.
Thanks,
Dustin
|
|
|
|
|
It would help to know what the error message is. The VB6 code looks good, so the only "quick" things to check are the .NET assembly is registered properly (using REGASM, not REGSVR32) and that the .NET Framework version that your assembly needs is installed properly.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
The error message I get when I try to run the external application alone in debug mode is "Wrapper.exe has encountered a problem and needs to close." Then if I click Debug, I get the Visual Basic error dialog:
Runtime error '-2147023170 (800706be)':
Automation error
The remote procedure call failed
If I start the Wrapper in debug mode and then run the external application in debug mode, I get "Run-time error 430: Class does not support Automation or does not support expected interface."
I am pretty sure the problem is that the CommConnector class immediately terminates in Wrapper.exe, and thus the external application cannot assign xCommConnector as an instance of Wrapper.CommConnection but cannot figure out why. When I step through the code it goes immediately from the End of the Class_Initialize Sub to the Class_Terminate Sub in the CommConnector class in Wrapper.exe
The assembly is registered through building the Server in debug mode in VS 2005 so it is registered correctly, and I have the 2.0 framework, which is what the Server was built on.
Dustin
|
|
|
|
|
You said that the VB.NET is known to be solid code. Is this something that your migrating to expose COM support? Is your VB.NET app only exposing this server when it's running or can any COM client instantiate it without the .EXE running?
Qualifying .NET Types for Interoperation[^]
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I don't believe the problem is with .NET interoperability because I also have a VB6 COM version of the Server that exposes the same types, methods, and variables to the Wrapper as the .NET version. When trying to use the COM version through the Wrapper, I still get the same problem with immediate instance termination.
|
|
|
|
|
OK, not you've got me confused. You have a COM-based Wrapper, written in what?, that can instantiate either a VB6 COM-based Server or a VB.NET version of the very same Server that is exposed to COM? Correct?
AFAICT, it is an Interop issue because your getting the "Run-time error 430: Class does not support Automation or does not support expected interface" error. It looks like your Wrapper isn't exposed to COM properly.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want open a file with my program when click on it in windows
|
|
|
|
|
please explain ur problem.
|
|
|
|
|
First, you have to create an association for your file's extension in Explorer. Open MyComputer, then Tools, Folder Options, File Types tab and you can add your extension there.
Next, your application has to be written to accept command line arguments. You can read more about getting your command line arguments from the Environment[^] class.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am making a program for a procurement company, i have a database full of suppliers i need code to search, filter search from the database, any other code ideas for this program are welcome. I also need other Ideas of functions to include, that would make my Project better
LynnNhari
|
|
|
|
|
|
I am making a program for a procurement company, i have a database full of suppliers i need code to search, filter search from the database, any other code ideas for this program are welcome.
LynnNhari
|
|
|
|
|
Hello, Iam having a problem with the amount of memory consumed by the aspnet process when performing find and replace operations on large strings. I have a scenario where iam reading a 26mb file into a string using streamReader and then performing upto about 40 find and replace operations.
The problem is, when I do this the aspnet process eats upto 500mb of RAM which is quite obviously not an acceptable overhead! Obviously reading a 26mb file into a string type probably wasnt the intended use for this variable type which why iam seeing such high ram usage.
Does anybody have any ideas of how to perform a find and replace on a large volume of data without the RAM usage spiralling out of control.
PS Ive already tried invoking a fast command line F+R utility which has worked and reduced the memory footprint - but the performance has dropped and the F+R operation now takes 2 minutes longer then before which isnt acceptable either!
I would be very grateful for any input or ideas on this!
Thanks Very Much , Michael
|
|
|
|
|
How are you doing it now ? string functions, or regex ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Dim stylesDataSet As DataSet<br />
Dim stylesDataTable As DataTable<br />
Dim stylesDataRow As DataRow<br />
<br />
Dim tempDataSet As DataSet<br />
Dim tempDataTable As DataTable<br />
Dim tempDataRow As DataRow<br />
<br />
<br />
Dim stylesCounter As Int16<br />
Dim token As String<br />
Dim replaced As String<br />
Dim SQLEval As String<br />
Dim oFile As System.IO.File<br />
Dim oRead As System.IO.StreamReader<br />
Dim oWrite As System.IO.StreamWriter<br />
Dim EntireFile As String<br />
<br />
Dim SQL As String<br />
'SQL = "EXEC tokenReplaceListExec <<CustomerID>>,<<ClientID>>,0,'" & paths("StyleFolder") & "','," & fileName & "'"<br />
SQL = "EXEC tokenReplaceList <<CustomerID>>,<<ClientID>>,0,'" & paths("StyleFolder") & "'"<br />
SQL = queryTokeniser(SQL)<br />
<br />
stylesDataSet = ExecuteDataTable(SQL)<br />
stylesDataTable = stylesDataSet.Tables(0)<br />
stylesCounter = 0<br />
<br />
oRead = oFile.OpenText(fileName)<br />
EntireFile = oRead.ReadToEnd()<br />
oRead.Close()<br />
<br />
<br />
<br />
<br />
<br />
EntireFile = Replace(EntireFile, vbCrLf, "")<br />
<br />
If Debug_Status = 1 Then<br />
oWrite = oFile.CreateText(fileName & ".test")<br />
oWrite.Write(EntireFile)<br />
oWrite.Close()<br />
End If<br />
<br />
<br />
fileFindAndReplace(fileName, vbCrLf, "")<br />
TOCReplace(fileName)<br />
<br />
Do While stylesCounter < stylesDataTable.Rows.Count<br />
stylesDataRow = stylesDataTable.Rows(stylesCounter)<br />
token = stylesDataRow("token")<br />
If Not stylesDataRow("Eval") Is System.DBNull.Value Then<br />
SQL = stylesDataRow("Eval")<br />
SQL = queryTokeniser(SQL)<br />
tempDataSet = ExecuteDataTable(SQL)<br />
tempDataTable = getLastTable(tempDataSet)<br />
tempDataRow = tempDataTable.Rows(0)<br />
replaced = tempDataRow.Item(0)<br />
Else<br />
If Not stylesDataRow("replacement") Is System.DBNull.Value Then<br />
replaced = stylesDataRow("replacement")<br />
Else<br />
replaced = ""<br />
End If<br />
End If<br />
<br />
<br />
EntireFile = Replace(EntireFile, token, replaced)<br />
stylesCounter = stylesCounter + 1<br />
Loop<br />
<br />
<br />
<br />
<br />
<br />
oWrite = oFile.CreateText(fileName)<br />
oWrite.Write(EntireFile)<br />
<br />
oWrite.Close()<br />
Hope this helps , iam basically using string = replace(string,find, replace)
|
|
|
|
|
Strings are immutable, so every time you do a replace, you create a new copy of the string.
You could try to use a StringBuilder instead. It uses a mutable string internally, so it doesn't create a new string for every replace.
---
b { font-weight: normal; }
|
|
|
|
|
hmm thats interesting and something I didnt know - I will try that as it sounds pretty uesful and bit more effecient. I have since discovered some improvements using binaryStream Reader/Write. By reading 5000 chars at a time doing the replace, then writing them to a new file ive lowered the memory footprint and kept a reasonable amound of speed. The problem with doing this is that if an item I want to replace is split accross two blocks then it wont be replace which is a bit of a pain in the ass!!
Does anybody know of a DLL or library item (third party or otherwise..) that I could use for a replace of this kind? Ive googled to no effect so far! Iam tempted to write a DLL in C++ to do a fast job and just include it in my .net project if possible, but I would rather use something already written as time isnt on my side!
|
|
|
|