|
These three functions don't do the same things, so your trying to compare apples to oranges to banana's.
Integer.Parse attempts to create an 32-bit signed integer out of a text string.
CInt attempts to convert the value of a numeric datatype into a signed 32-bit integer value.
CType attempts to convert one datatype into another datatype. This works with numeric types, objects, structures, classes, interfaces, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ok thanks a lot You really are a very helpfull resources
Now for the last question :
Dim ocls as Classname
or
Private (public etc..) ocls as Classname
in the Code-Behind (not in methods).
I'm sorry for all those question, it's just thing i havent paid attention, in my learning process.
|
|
|
|
|
At this level, both of your statements generate the exact same code. If Public or Private is specified, the Dim keyword becomes optional. If there is no access modifier specified, Dim must be used and the variable is Private by default. These three statements do the exact smae thing:
Class myClass
Private Dim mstrLine1 As String
Private mstrLine2 As String
Dim mstrLine3 As String
End Class
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Great, thank you very much.
|
|
|
|
|
I have a word macro (W97) that reads rich text from a database field assigns it to a rich text box control and pastes it into the word doc.
The macro has been tested on four development machines and it runs fine. However, when it is moved to a production PC it produces error 429 can't create object. This error occurs on the rich text assignment line.
rtb.TextRTF = strSelection
Is there anything special ( a DLL or OCX that should be registered) that should be done to release the macro. What is special about the development machines that allow the macro to run?
|
|
|
|
|
There are a bunch of reasons why this error could come up, but none of them have anything to do with the RichTextBox. It's more likely that it is a problem with the Data Access Components. Try updating the components with MDAC 2.7 SP1 (at least).
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
----------------------------------------------------------------------------
How do I set different tooltip message for different selected Listviewitems?
My ListView is in Detail mode and FullRowSelect = true
|
|
|
|
|
ToolTips are not supported on ListViewItems.
What you'll have to do is handle the MouseHover event of the ListView control, then use the ListView .GetItemAt() method to return the ListViewItem that the mouse is over. You can then use whatever you want from that to set the Text of your ToolTip control. Handle the MouseHover event of the ListView to display the ToolTip.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thankz for the reply & tips, but im having abit problem. My program's listview display a report in such way as it will identify the row where there are error in any of it's colume and highlight it in pink. I'm suppose to display a tooltip on selecting of the "error" row and display a message stating the column that are incorrect.
How should i do it?
|
|
|
|
|
If your code highlights a ListViewItem in Pink because of an error, then you can also set that ListViewItems Tag property to some value to signify the same. You can then check that Tag property when you go to set the ToolTip Text. If the Tag signifies an error, setup the ToolTip. If not, clear it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
After loading an image file in a picturebox with picturebox.Image = Image.FromFile(Foto.Path) i want the file deleted from the hard disk.
First I dispose the image in the picturebox (picturebox.Image.Dispose()) an then I delete teh file (System.IO.File.Delete(Foto.Path))
I recieve the message acces denied
Can anybody help me
Thnks
Jo De Decker
|
|
|
|
|
The Image object that you originally used to load the image from the file still has the file open. You called .Dispose() on the Image object in the picturebox, not on the Image object that loaded the file.
To work around this little "feature", see this[^] article on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
While testing a service we've setup in Visual Studio / VB.NET we've found that the service will start without a problem if the files that it is monitoring are local to the machine the service is running on.
As soon as we try to monitor a file on our network, and start the service, the following security message is thrown:
Service cannot be started. System.UnauthorizedAccessException: Access to the path "\\TheServer\D Drive\FTP Files\OpenActions.csv" is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.File.GetLastWriteTimeUtc(String path)
at System.IO.File.GetLastWriteTime(String path)
at FileChangeMonitor.ChangeMonitor.CheckFileChanged(String FileName, DateTime& LastChangeDate) in E:\_MyFiles\Vb.NetProjects\Development\FileChangeMonitor\FileChangeMonitor\ChangeMonitor.vb:line 171
Any suggestions on what needs to be changed via security is appreciated.
Lost in the vast sea of .NET
|
|
|
|
|
By default services run under the SYSTEM account. That wont have any rights to access files on the network. Each service can be configured seperatly. This can be done under Control Panel->Administration->Services->Right Click->Properties->LogOn (Im not sure about the names because Im using a german windows version).
|
|
|
|
|
That worked... Thanks!!
Lost in the vast sea of .NET
|
|
|
|
|
A second problem your going to run into is that the FTP server will not lock the file that is being uploaded to it. Your service has to take into account that it cannot know when the file is completely written to the disk by the FTP server. The FileWatcher will notify you when the file is created, not when it is closed by the FTP Server.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You brought up a very good question. How do we know if a file that we're looking for with the service is closed by the FTP process? I'm not sure what the answer is? Any suggestions?
Lost in the vast sea of .NET
|
|
|
|
|
The short answer is, you can't.
Most FTP server implementations (and I can't tell you which ones do and don't do this) don't lock the files they are writing for exclusive write access. This means that you can open the file while the FTP server is writing it.
You can not open the file for exclusive (not shared) access while you read the file, because this might have the affect of forcing the FTP server to abort the transfer when it can no longer write to the file.
Other that testing for exclusive read access, there is no way to find out when the file is completely written.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need to get the date to show in something such as a textbox or whatever. But everything I try doesn't show the date. I set the textbox to read only and everything. i am using ;
<br />
Dim D As Date<br />
D = Today<br />
TextBox7.Show()<br />
can anyone help me?
thanx
|
|
|
|
|
try -
textbox.text = d.tostring()
|
|
|
|
|
Hey, i am trying to figure out why ReadFile isn't working the way it should in VB.NET. The problem is that I call ReadFile on some file that i open with CreateFile, and it fills a buffer with the first couple of bytes from the file.. that is fine. but when i call ReadFile again, it still returns the same first bytes.. as if it didnt increment the file pointer. Then, i tried checking the file pointer value before and after each call to readfile.. and what seems to happen is that every time readfile is called, the file pointer is reset to 0, because after the first, or second call to readfile the file pointer is correct (the number of bytes i read using the function).. so i guess it gets reset to 0 before it fills the buffer.
here is the code if anyone can help:
<br />
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer<br />
<br />
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer<br />
<br />
Declare Function ReadFile Lib "kernel32" (ByVal hFile As Integer, ByVal destBuffer() As Byte, ByVal nNumberOfBytesToRead As Integer, ByRef lpNumberOfBytesRead As Integer, ByRef lpOverlapped As OVERLAPPED) As Integer<br />
<br />
...
<br />
<br />
Dim hDisk As Integer<br />
Dim bytesReturned As Integer<br />
<br />
hDisk = CreateFile("E:\somebigfile.dat", _<br />
GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, _<br />
Nothing, OPEN_EXISTING, 0, 0)<br />
<br />
If hDisk = INVALID_HANDLE_VALUE Then Exit Sub<br />
<br />
me.Text = SetFilePointer(hDisk, 0, Nothing, FILE_CURRENT)<br />
<br />
Dim dest() As Byte<br />
ReDim dest(1023)<br />
Dim destLen As Integer = dest.Length<br />
<br />
ReadFile(hDisk, dest, 1024, bytesReturned, Nothing)<br />
PrintData(dest, txt1) 'just a function that writes the data to a textbox txt1<br />
<br />
me.Text &= " " & SetFilePointer(hDisk, 0, Nothing, FILE_CURRENT)<br />
<br />
ReadFile(hDisk, dest, 1024, bytesReturned, Nothing)<br />
PrintData(dest, txt2)<br />
<br />
me.Text &= " " & SetFilePointer(hDisk, 0, Nothing, FILE_CURRENT)<br />
<br />
ReadFile(hDisk, dest, 1024, bytesReturned, Nothing)<br />
PrintData(dest, txt3)<br />
Thank you for any help!!!! This is driving me nuts!!!
r -€
|
|
|
|
|
First, according to the MSDN docs on ReadFile, your buffer should be passed ByRef, not ByVal. Second, are you checking the value of bytesReturned after each read?
Why are you P/Invoking theres functions in the first place? They're wrapped by the System.IO namespace. Using the classes found there is MUCH easier than what your doing. I only say this because your posted code isn't doing anything that these classes couldn't handle.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well, the buffer is an array, which seems to automatically act as a pointer when it is passed to C functions, also I saw the declaration with ByVal many places and it seemed to work.
I checked bytesReturned after each call, it is 1024. I also tried clearing the array before each call to ReadFile, and it still fills the buffer each time with the first bytes of the file.
I realize now I can use the System.IO namespace and FileStream and such, but this has become more of a curiosity on my part. I am befuddled as to why API functions (I had similar problems calling ZLib DLL functions from VB.NET) don't work properly in VB.NET. Maybe it is something with the managed code heap or something?
Thank you for your reply, however.. if anyone finds anything more on the subject please let me know.
r -€
|
|
|
|
|
How to set the first parameter of URLDownlofToFIle() in VB.
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
I have created a dll ,which makes use of the urldownloadtofile win32 API.
This dll works fine from within VB.
But when I access it from ASP ..the urldownloadtofile function ..wont work ..
I supose it has got to do something with the first parameter :
pCaller
Pointer to the controlling IUnknown interface of the calling Microsoft ActiveX component (if the caller is an ActiveX component). If the calling application is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component (such as an ActiveX control within the context of an HTML page). This parameter represents the outermost IUnknown of the calling component. The function attempts the download within the context of the ActiveX client framework and allows the caller's container to receive callbacks on the progress of the download.
Please help me out...
|
|
|
|
|