|
hi,
if File.Open does not do what you expect, then maybe your expectations are incorrect. Go and check the documentation. That is what it is for.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi all...
Please suggest me how can I make my "Image Viewer" as default program for images through VB.Net.
Thanks.
Gagan
|
|
|
|
|
http://www.codeproject.com/KB/vb/VBFileAssociation.aspx[^]
Here is what you are looking for , "Image Viewer" as default program for images through VB.Net , you need to make a registry entry to associate .jpg, .bmp , etc file to your application and then when ever some body clicks on this file your application will be launched and name of the file (image file ) will come as command line arguments , you can than use it and display image in you Image Viewer
Thanks
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Thanks for your suggestion but I already did that.
Now I can open image files through my program and Windows's default program.But the main thing is that I want to make my "Image Viewer" as default program for images through VB.Net programming.The same thing can be done as right click on image->properties->Change.(open with program).
Please help me how can I do it through programming.
Thanks.
Gagan
|
|
|
|
|
how can i write or transfer or save the items from listview to a
word document or a text file?
i m using vb6
pls guide me.
purvas
|
|
|
|
|
|
Hello,
I'm having some difficulties with Control Collections and multiple forms. I set up a control collection to use on the second form of my project. However, I am getting the following error in the .vb file for the second form:
Argument not specified for parameter 'host' of 'Public Sub New(host As System.Windows.Forms.Form)'.
However, in the New subroutine of the control collection there is clearly a link made between the two:
Public Sub New(ByVal host As System.Windows.Forms.Form)
Form2 = host
Me.AddNewTextBox()
End Sub
It's confusing me because when I type Form2 = host, I don't see a Form2 class available in the drop down menu of MS Studio 2008, only a reference to the ReadOnly object.
I would greatly appreciate any help you all could provide me with.
Thanks, and have a great week!
|
|
|
|
|
Hi,
Error messages contain file names and line numbers, they often point you to the exact location of the problem. In general it is useful to tell your IDE to always display line numbers in editor windows; for Visual Studio, look under menu Tools/Options/...
That, or a little google search on "Argument not specified for parameter" will tell you exactly what the problem is. I leave it up to you to discover it.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thanks for the Reply Luc,
I actually figured it out, and when creating the global control collection object in my Form2 class I was using the statement Private _MyControlCollection As New ControlCollection. The New was causing the problem.
I should have been using the statement Private _MyControlCollection As ControlCollection.
|
|
|
|
|
i have 2 table Rabotnici and zaplata
this my code
Dim a As Date
Dim b As Date
a = FormatDateTime(DateTimePicker1.Value, DateFormat.ShortDate)
b = FormatDateTime(DateTimePicker2.Value, DateFormat.ShortDate)
Dim selectData = "select rabotnici.* from rabotnici,zaplata where rabotnici.rabotnik_name <>zaplata.worker_name and rabotnici.data_rabota<>zaplata.data_rabota and rabotnici.rabotnik_name='" & ComboBox1.Text & "' and rabotnici.data_rabota>='" & a & "' and rabotnici.data_rabota<='" & b & "' order by rabotnici.data_rabota"
but have a error I don't know where is my error
give me this error "Data type mismatch in criteria expression"
|
|
|
|
|
I assume that the error is a run-time error and not a compile-time error.
I have to say that I do not know the answer to your problem, but in order to track down where the error is I would suggest that you try implementing your selectData statement in stages.
e.g.
Dim selectData = "select rabotnici.* from rabotnici,zaplata
run that, see if you get an error. If so post again for help.
If not,
Dim selectData = "select rabotnici.* from rabotnici,zaplata where rabotnici.rabotnik_name <>zaplata.worker_name
run that etc.
then
Dim selectData = "select rabotnici.* from rabotnici,zaplata where rabotnici.rabotnik_name <>zaplata.worker_name and rabotnici.data_rabota<>zaplata.data_rabota
and so on until you find the part giving the problem.
Often, by doing this, the answer becomes obvious. But if not then post again.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
SQL statements that test date fields need a string such as ... WHERE date > '2009-02-11' ... and that is what your selectData is doing; however you are attempting to store the result of FormatDateTime, a string, into a Date variable, and that is where the problem is IMO. Just change the first two lines!
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi all,
I want to get the ControlName of .NET properties in VB6 code, just like described in this article: http://msdn.microsoft.com/en-us/library/ms996405.aspx . But unfortunately, it doesn't work for me. I always got 0 for bufferMem.
bufferMem = VirtualAllocEx(processHandle, 0, size, MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE)<br />
If bufferMem = 0 Then<br />
Error Err, "VirtualAllocEx API Failed"<br />
End If
What am I doing wrong?
|
|
|
|
|
I am not totally sure what you need. See if these help - MSDN[^], CP[^], CP[^]
|
|
|
|
|
Thanks for your reply.
But actually what I need is to access the control of .NET application automatically, such as its button, listview or windowedit. I build code in VB6 to validate this application. Usually we can get the ControlID, but ControlID of .NET control is unique everytime we launch the application. So we need to get the ControlName instead. But in my way to get the ControlName, I got stuck in VirtualAllocEx function that always gives me null result *sigh*. Hope anyone can help me.
|
|
|
|
|
Hi All,
I have managed VirtualAllocEx . Before I declared this function as Private . Then when I moved it to Module file and changed it to Public, I don't get 0 anymore for bufferMem . Also I need to set lpAddress as ByVal . Otherwise, the length of controlName (retLength ) that given is twice than correct length (I don't know exactly how this happens).
Declare Function VirtualAllocEx Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal flAllocationType As Long, _
ByVal flProtect As Long) As Long
Now I got the correct retLength , but unfortunately retVal is 0, return the error description: Invalid procedure call or argument.
If retLength <> 0 Then
'Now read the component's name from the shared memory location.
retVal = ReadProcessMemory(processHandle, bufferMem, bytearray, size, VarPtr(written))
If retVal = 0 Then
Error Err 'ReadProcessMemory API Failed
End If
End If
My declaration of ReadProcessMemory is:
Declare Function ReadProcessMemory Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal lpBaseAddress As Long, _
lpBuffer As Any, _
ByVal nSize As Long, _
lpNumberOfBytesRead As Long) As Long
And when I run the whole thing (ignore the retVal value), I got error in WideCharToMultiByte :
Function ByteArrayToString(bytes As String, length As Long) As String
Dim retValStr As String
Dim l As Long
If IsWin9x() Then
retValStr = Left(bytes, InStr(1, bytes, Chr(0)) - 1)
Else
retValStr = String$(length + 1, Chr(0))
l = WideCharToMultiByte(CP_ACP, 0, bytes, -1, retValStr, length + 1, Null, Null)
End If
ByteArrayToString = retValStr
End Function
The error is saying:
Run-time error '94':
Invalid use of Null
Any idea?
Here is the code:
Function GetWindowsFormsID(ByVal wnd As Long) As String
Dim PID As Long 'pid of the process that contains the control
Dim msg As Long
' Define the buffer that will eventually contain the desired
' component's name.
Dim bytearray As String * 65526
' Allocate space in the target process for the buffer as shared
' memory.
Dim bufferMem As Long
' Base address of the allocated region for the buffer.
Dim size As Long
' The amount of memory to be allocated.
Dim written As Long
' Number of bytes written to memory.
Dim retLength As Long
Dim retVal As Long
Dim errNum As Integer
Dim errDescription As String
size = 65527 'Len(bytearray)
' Creating and reading from a shared memory region is done
' differently in Win9x than in newer Oss.
Dim processHandle As Long
Dim fileHandle As Long
msg = RegisterWindowMessage("WM_GETCONTROLNAME")
If Not IsWin9x() Then
On Local Error GoTo Error_Handler_NT
Dim dwResult As Long
Call GetWindowThreadProcessId(wnd, PID)
processHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, 0, PID)
If processHandle = 0 Then
Error Err 'OpenProcess API Failed
End If
bufferMem = VirtualAllocEx(processHandle, 0, size, MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE)
If bufferMem = 0 Then
Error Err 'VirtualAllocEx API Failed
End If
' Send message to the control's HWND for getting the
' Specified control name.
retLength = SendMessage(wnd, msg, size, ByVal bufferMem)
If retLength <> 0 Then
' Now read the component's name from the shared memory location.
retVal = ReadProcessMemory(processHandle, bufferMem, bytearray, size, VarPtr(written))
If retVal = 0 Then
Error Err 'ReadProcessMemory API Failed
End If
End If
Error_Handler_NT:
errNum = Err
errDescription = Error$
' Free the memory that was allocated.
retVal = VirtualFreeEx(processHandle, bufferMem, 0, MEM_RELEASE)
If retVal = 0 Then
Error Err 'VirtualFreeEx API Failed
End If
CloseHandle (processHandle)
If errNum <> 0 Then
On Local Error GoTo 0
Error errNum 'errDescription
End If
On Local Error GoTo 0
Else
On Local Error GoTo Error_Handler_9x
Dim SA As SECURITY_ATTRIBUTES
fileHandle = CreateFileMapping(INVALID_HANDLE_VALUE, SA, PAGE_READWRITE, 0, size, Null)
If fileHandle = 0 Then
Error Err 'CreateFileMapping API Failed
End If
bufferMem = MapViewOfFile(fileHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0)
If bufferMem = 0 Then
Error Err 'MapViewOfFile API Failed
End If
Call CopyMemory(bufferMem, bytearray, size)
' Send message to the treeview control's HWND for
' getting the specified control's name.
retLength = SendMessage(wnd, msg, size, bufferMem)
' Read the control's name from the specific shared memory
' for the buffer.
Call CopyMemoryA(bytearray, bufferMem, 1024)
Error_Handler_9x:
errNum = Err
errDescription = Error$
' Unmap and close the file.
UnmapViewOfFile (bufferMem)
CloseHandle (fileHandle)
If errNum <> 0 Then
On Local Error GoTo 0
Error errNum 'errDescription
End If
On Local Error GoTo 0
End If
If retLength <> 0 Then
' Get the string value for the Control name.
GetWindowsFormsID = ByteArrayToString(bytearray, retLength)
End If
End Function
|
|
|
|
|
Hi,
This is a completely blocking issue during development. I have previosuly posted a few messages about it but I haven't received a satisfiying answer from one yet. I am working with IMAPI2. When I load a media on tray, I am getting UnAuthorizedAccess Exception error message.
There should be a way to give essential permission to specific drive or a folder. I know there is however, neither the demanding permission from OS nor Asserting a persmission do not make any sense to Vista 64.
What is putting me in thoughts that how some other software developers find solution to over come authorization problems. I don't have broad knowledge about authorization and permission issues.
If you know any well developed class or a sample code for authorization please let me know. I primitively tried to give permission exclusively to executable file under bin/debug but I realized that the application has already gotten full permission. But the permission is not working at all.
Any help at professional level will be highly appreciated.
Thank you.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
hi,
how i can add macromedia flash as a component into vb project?
|
|
|
|
|
|
Hello everybody,
I'm using a class which creates an arraylist of filtered fileinfo objects. Calling the class like
public source as new clsFileOp
public target as new clsFileOp
....
source.collectFiles(dir) '--> fills the arraylist within the class "source"
target.collectFiles(dir) '--> fills the arraylist within the class "target" which should result in a "files" property within the "source" and the "target" class.
Unfortunately I can't find out how to get the name of the active class from within the class (there's no "name" property). I'm heading to write a logfile which contains entries like "File ... added to arraylist ..." (source or target) while adding the fileinfo objects to the classes "files" property.
Can someone help, please?
Thank you
Michael
|
|
|
|
|
If you want information about the class (this includes the name), try GetType(Me) or Me.GetType. This returns a Type object, which has information about the fields, methods, properties, etc. However, it also has the Name property. Use that
Me.GetType().Name
GetType(Me).Name
You can also get this information from some external files - if you have a spare afternoon, look into the System.Reflection namespace
|
|
|
|
|
Thank you very much - I'll try it asap, the Type object as well as your additional hint.
|
|
|
|
|
Trying the above suggestion I get no usable results.
In my example, I want to print the Name "Source", which I gave the class instance ("Dim Source as new clsFileOperations"), into a log from within the running instance. The Me.Gettype().Name results in "clsFileOperations" printed into my log instead.
Or do I misunderstand something else?
|
|
|
|
|
If TreeView1.SelectedNode.Parent IsNot Nothing Then
SoruTableAdapter.sinif_Gore(YahapDataSet.soru, TreeView1.SelectedNode.Name)
Soru1TableAdapter.sinif_sorgula(YahapDataSet.soru1, TreeView1.SelectedNode.Name)
ElseIf TreeView1.SelectedNode.Parent.Parent.Name IsNot Nothing Then
SoruTableAdapter.ders_gore(YahapDataSet.soru, TreeView1.SelectedNode.Name)
Soru1TableAdapter.ders_gore(YahapDataSet.soru1, TreeView1.SelectedNode.Name)
ElseIf TreeView1.SelectedNode.Parent.Parent.Parent.Name IsNot Nothing Then
SoruTableAdapter.unite_gore(YahapDataSet.soru, TreeView1.SelectedNode.Name)
Soru1TableAdapter.unite_gore(YahapDataSet.soru1, TreeView1.SelectedNode.Name)
ElseIf TreeView1.SelectedNode.Parent.Parent.Parent.Parent.Name IsNot Nothing Then
SoruTableAdapter.Konu_gore(YahapDataSet.soru, TreeView1.SelectedNode.Name)
Soru1TableAdapter.Konuya_gore(YahapDataSet.soru1, TreeView1.SelectedNode.Name)
End If
error: Object reference not set to an instance of an object.
help me..
(bu arada ben türküm başka türkler varsa burada yardımcı olabilir mi? )
|
|
|
|
|
Perhaps nothing is selected in the treeview. This would cause a NullReferenceException, because TreeView1.SelectedNode would be Nothing
|
|
|
|
|