|
Death to vb6! Take vb6 to the noose!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hello everybody. I have a file that is spaced with NULL instead of standard spaces. LIKE SO...
COMPANYNAME
C(NULL)O(NULL)M(NULL)P(NULL)A(NULL)N(NULL)Y(NULL)N(NULL)A(NULL)M(NULL)E(NULL)
I'm trying to make a utility that will remove or add the NULL spacing. First I started on the add function. Here's what I have
Private Sub btnOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenFile.Click
Dim FileName As String = ""
With dlgOpenFile
.InitialDirectory = "C:\Stuff\Office2K3.SP2"
.Filter = "All Files|*.*"
End With
If (dlgOpenFile.ShowDialog = Windows.Forms.DialogResult.OK) Then
FileName = dlgOpenFile.FileName
'Dim sr As System.IO.StreamReader = Nothing
'sr = New System.IO.StreamReader(FileName)
'CurrentFileContents = sr.ReadToEnd
Dim fs As System.IO.FileStream = New System.IO.FileStream(FileName, IO.FileMode.Open, IO.FileAccess.Read)
Dim strLength As Integer = Convert.ToInt32(fs.Length)
Dim fileData As Byte() = New Byte(strLength) {}
fs.Read(fileData, 0, strLength)
fs.Flush()
fs.Close()
For Each x As Byte In fileData
txtOut.Text &= Convert.ToChar(x) & Chr(&H0)
Next x
'For Each x As Char In CurrentFileContents
'txtOut.Text &= x & vbNullChar
'Next x
'sr.Close()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
If (CurrentFileContents = "") Then
btnOpenFile_Click(sender, e)
End If
Dim null As String = vbNullChar
Dim newFile As String = ""
For Each x As Char In CurrentFileContents
newFile &= x & CStr(vbNullChar)
Next x
txtOut.Text = newFile
End Sub
I've tried 2 different ways. I tried using a streamreader and dumping the file into a string. Then iterate with a for each loop and append a NULL char after each value. This results in a string with 1 Char in it, the first one "C". If I remove the NULL char, the string will be complete.
The other method was using a byte array. This resulted in a dump but without the NULL bytes.
I've researched and there is alot of "NULL removal" or "MYSQL and NULL in DateField" but I see nothing on NULL padding. Any takers????
|
|
|
|
|
It looks like you have a unicode file, not an ascii one... I am sure, armed with this knowledge, google will help you out more than I can
|
|
|
|
|
The file is using a different encoding than ASCII, most likely Unicode. Change the StreamReader line to this to have it try and determine the encoding automatically:
Dim sr As New StreamReader(filename, True)
|
|
|
|
|
Hi everyone,
I'm using VB6.0 and have code below for run some processes, but I have this error: Automation Error: The system can't find the file specified.
Here's my code:
Private Sub cmdRun_Click()
{
Dim wsh as New IWshRuntimeLibrary.WshShell
wsh.Run App.path + "\Process1.exe", 1, True
wsh.Run App.path + "\Process2.exe", 1, True
}
I'm sure that the files Process1.exe and Process2.exe are exist and are in correct path. Any Idea?
Thanks.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Pedram,
Where is App.path pointing to?
PJC
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi Paul, thanks for reply.
This is my application .exe file path, if it's in (for example) C directory App.path is "C:\".
I tested CurrDir instead of App.path but nothing changed.
Thank you again.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Where does Process1.exe and Process2.exe reside? You should make sure that App.path is indeed pointing to the location of those two.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I tested Shell App.path + "\Process1.exe" and it worked so my file paths are correct.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
For laughs and giggles, do a debug.print App.path + "\Process1.exe" and debug.print App.path + "\Process1.exe"
Copy and paste each result into the run window and make sure the .exe's run that way.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hello, thank you for your reply,
I'm sure that these file paths are exist and correct. I tested your idea before.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
I second that. It doesn't hurt to put in a little debug diagnostics.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
OK, I found it...
Private Sub cmdRun_Click()
{
Dim wsh as New IWshRuntimeLibrary.WshShell
wsh.Run Chr(34) & App.path + "\Process1.exe" & Chr(34), 1, True
wsh.Run Chr(34) & App.path + "\Process2.exe" & Chr(34), 1, True
}
Thank you all...
While (true) { Human.isLearnable = true; }
|
|
|
|
|
That'll do it every time. Congrats on solving it.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I am running some initializing code for the forms ComboBoxes in the Form Load event. I am populating some ComboBoxes using the ComboBox.DataSource = (Array of a type of object). The object is a listitem class, i set the DisplayMemeber equal to the display string in the object and ValueMember equal to the ID of the object, sample displaystring = ProductName and ID = ProductID.
The SelectedValueChanged event of the combobox triggers a repopulation of the products information for the selected product. The problem is the SelectedValueChanged event is triggering on the Form Load when the DataSource is set for the combobox. I do not want this event to happen during the Form Load event. I only want this event to trigger after the form has loaded and a user changes the SelectedValue or the SelectedValue is changed within code that is no fired off by the Form Load event.
Is there either a way to suppress the ComboBox events, SelectedValueChanged, SelectedIndexChanged, etc., or a way to detect that I am still in the Form Load event/state and conditionally use that to not execute the code in the SelectedValueChanged event?
|
|
|
|
|
add a module level boolean like mblnInit and set it accordingly during the new/load events
IE:
sub form_load (byval sender as object, ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mblnInit = true
...all your load code here...
mblnInit = false
end sub
In the combo_selectvalue changed:
sub SelectedValueChanged
if not mblnInit then
...repopulate code...
end if
end sub
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Looks to be the old KISS method
I thought there were state trackers, but this works just as well.
|
|
|
|
|
i wants to create property in a class at run time with different names and datatypes.. thanks
Muhammad Ismail Khan
SoftWare Developer CRM(Islamabad), Pakistan
|
|
|
|
|
Possible, but hardly practical. You'd have to use reflection to do this. I don't know of any examples on the web, nor do I have any myself.
Usually, if this comes up, I would have to question the design. Why do you think you have a need for this?
|
|
|
|
|
Dave Kreskowiak wrote: Why do you think you have a need for this?
Looking at the subject line, rum time? I'm so there after a long day. Captain Morgan with Dr. Pepper
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I'm out of the Captain, but I've got a gallon of Jack Daniels on the kitchen counter!
|
|
|
|
|
Dave Kreskowiak wrote: got a gallon of Jack Daniels on the kitchen counter!
Whoohoo. That'll work as well.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
hai guys,
i am distributing a external winodow hook dll to the users system32 folder while installing my app. but after the installtion, when program is laucned, the dll loaded in vista, but no hooking. if restarted the pc only it works. but no problem in xp. it hooks and works fine after the installation.
whats wrong?
this is th innosetup code
Source: "D:\myproject\distribusion\xxxhook.dll"; DestDir: "{sys}"; Flags: ignoreversion
btw, it is a vb6 application.
|
|
|
|
|
My first question would be is the user running the code an Administrator?? You said you're using WIndows hooks, but not just anyone can use those functions.
|
|
|
|
|
Hai dav,
i am running in the admin account.
but here i dont think account is a concern in my openion.
hooks and permissions have no connection if i am correct.
the main think here, after restarting the machine, the hook works in vista.
but not imediatly after the installation.
D
|
|
|
|