|
I have a vb6 app with no forms that is run in dos window. How do I output to the window if I want to send a message. No Msgbox (I don't want things popping up)
so I want something like this
c:\ingroup
c:\You must provide a parameter with ingroupc
c:\Example ingroup /i
Something like that if possible?
thanks
|
|
|
|
|
VB6 couldn't target a console app. You have to call into the Win32 API to create a console and output to it. You might want to try here[^] for a couple of console classes for VB6.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks I will take a look at the samples.
Do you happen to know how I pass a error level code back after terminating the code? I want to check in the batch file for errors in the code.
Thanks
I found one thing but I put it in the code and tested it and it booted me out of VB and I lost it
Forgot to save.
|
|
|
|
|
Also wanted to ask if there is an easier way to do this in vb.net?
|
|
|
|
|
All of this is trivial in VB.NET since it, and any other language targeting the .NET Framework, can target a console app. Support for I/O redirection and exit codes are included. Even better support is included in the .NET Framework 2.0 and Visual Studio/Basic .NET 2005.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That would be done with the ExitProcess Win32 API function. VB6 can't do it natively.
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
.
.
ExitProcess(returnCode)
This will have the effect of terminating your app immediately, so you better have everything cleaned up before you call this.
Also, when you launch a VB6 app from a batch file, it won't wait for it to complete. Unless, of course, you tell it to using:
START /W vbApp.exe
...ERRORLEVEL statements go here
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi
i have strange problem in my project the keybord some time hange and you must trun off the keyborad sokt and trun on again for can type again can you help me and how i save picture in database and view in vb6 program
|
|
|
|
|
Hi! Thanks for you reply.I made a little example using the AsyncCallBack class and BeginInvoke() but i reached a result that i didn't expected.I ran the beginInvoke in a different thread and the callback function is located at the form(main thread).After the beginInvoke() my code proceeded(as expected).Then the execution passed to the callback function(in the form) but it wasn´t running neither on the thread or form context, it was in a completly different thread.Strange?For me it was because i was hopping that the callback executed in the form's context.Am i doing anything wrong or is this correct?
|
|
|
|
|
This is the normal behavoir of the AsyncCallBack class. However, you should not let this tread modify any of the forms controls. This is an Windows UI rule and if you violate it you will pay the price . If you need to modify the forms controls during the call back do the following in the call back function.
Private Sub MyFunct() 'This is your callback function.
If Me.InvokeRequired = True Then
Me.Invoke("Your Delegate here") 'You can create a delegate that matches the call back
'and pass that in. After the invoke the function will be recalled and you will
'end up in the else part of this block
Else
'Do your work here this code is now executing on the UI thread.
End If
End Sub
Forever Developing
|
|
|
|
|
Ok! I made that last question because i have and app that raises an event in a thread and the handler is in the main form. The context of the handler is the thread which fired the event but this isn't happening with the async. Callback, thus my confusion. When i raise and event and check out the name of the current thread it gives me the thread that fired the event, if i check the name with the callback the name isn't from the thread that executed the beginInvoke().But if you say that this is the normal procedure fine by me One less problem for me to handle. But just to know, in what thread is it running? Is it a thread from the thread pool?A system thread?Just out of curiosity...
PS:Ye, i know that is a mistake to modify the UI from another thread.I found out the hard way Thanks for your concerne.
|
|
|
|
|
OK, this is what I belive is happing. The AsyncCallback is creating a new thread to do the work. I am not sure where this tread comes from but I belive it is from the thread pool Dot Net creates on startup. When you call BeginInvoke that tread starts on the function you have told it to execute. When it is finished it will call your finshed call back.
Forever Developing
|
|
|
|
|
Thanks a bunch.
That was what i though.
|
|
|
|
|
Help!
We're getting ready to deploy and I'm trying to build a Launcher application that will run on non-.NET platforms (COM or Win32).
Is there any way to build or compile a VB .NET application to output COM or Win32 code, or do I have to re-write this thing in Visual Studio 6 or InstallShield?
We're shipping tomorrow! Please help!
|
|
|
|
|
This depends on the Level of the Visual Studio Dot Net you have installed. If you have the ability to create C++ applications then you can create byte code exe's "Win32" in C++. If you are asking if a VB.Net application can be compiled as byte code, the answer to that is NO. If you use VB 6.0 then you will get semi-byte code but you will still need the vb runtime. The vb 6 runtime is installed by default for Windows 2000 and greater.
For a very simple launch I would create a native C++ program.
For a more complicated on I would probably use InstallShield. However, I am not sure what you mean by Launcher since InstallShield is a installer application.
Best of Luck
Forever Developing
|
|
|
|
|
I've found numerous examples on doing interop by creating a NEW Excel file, but would like to open an existing Excel file from VB.NET and interop with that. I've tried "guessing" how to modify the examples, but with no luck. Can anyone point me to an example of how to open an existing Excel file in VB.NET so I can interop with it?
Thanks for any help on this...
Hal in AZ
|
|
|
|
|
hey hal,
try...
myExcel.Workbooks.Open(pathToFile)
hope this helps
-jim
|
|
|
|
|
Jim,
Worked fine. Thanks very much! Funny that out of 3 different books no one mentioned this.
Thanks again,
Hal
Hal in AZ
|
|
|
|
|
Hi!
I have a doubt about how to handle an event asynchronously.I have an event and a handler for that event, but after the raiseevent instruction the handler runs synchronously and my thread has to wait for the handler to terminate it's code.How can i treat this event asynchronously using the raisevent instruction? And what about delegates?Is it easier to perform with delegates?
|
|
|
|
|
I am not sure but I don't think you can accomplish this with RaiseEvent. However, you can use the
AsyncCallback class. Check your local help files for more information on how to use this class.
Best of Luck
Forever Developing
|
|
|
|
|
Hi,
Is there a way to add file names from a folder on the hard drive to a list box and only show two types of file extensions ie txt and dat files using vb6.
Thanks
|
|
|
|
|
Here you go.
1) You need to add a referance to the Microsoft Scripting Runtime.
2) Add a Command Button to the form
3) Add a ListBox to the form
4) Have Fun
'///BEGIN CODE///
Private Sub Command1_Click()
Dim fso As New FileSystemObject
Dim fld As Folder
Dim fi As File
Dim I As Long
Set fld = fso.GetFolder("C:\")
For Each fi In fld.Files
If MatchesExtension("txt", fi.Name) Then
List1.AddItem fi.Name
End If
Next
End Sub
'Takes a filename and a file extension to match
'Works in reverse on the file name looking for the last
'period character. Once found the string is then compared to the
'passed in sFileExtension parameter.
Private Function MatchesExtension(sFileExtension As String, sFileName As String) As Boolean
Dim sChar As String
Dim sTemp As String
Dim I As Long
MatchesExtension = False
For I = Len(sFileName) To 1 Step -1
sChar = Mid(sFileName, I, 1)
If sChar = "." Then
If sTemp = sFileExtension Then
MatchesExtension = True
Else
MatchesExtension = False
End If
Exit For
End If
sTemp = sTemp & sChar
Next I
End Function
'///END CODE///'
Forever Developing
|
|
|
|
|
Thank you so much for this code. One question. Does this only wory for txt files or can other extensions be used. The two file extensions i'm trying to display is .cdimage and .dvdimage
I tried changing the "txt" in the code you gave me but it did not work.
Any ideas.
Once again Thank you for the code
|
|
|
|
|
Sorry about that. There is a small bug. I tested it with txt files.
Here is the fix you need to make.
In the MatchesExtension Function change
sTemp = sTemp & sChar
TO
sTemp = sChar & sTemp
if you want to add different/more file types you can do some thing like this in the
commandbutton click event
For Each fi In fld.Files
If MatchesExtension("cdimage", fi.Name) Then
List1.AddItem fi.Name
End If
If MatchesExtension("dvdimage", fi.Name) Then
List1.AddItem fi.Name
End If
'Keep adding file extensions. by duplicating the code above
Next
Forever Developing
|
|
|
|
|
Thank you so much. You the man
I'm wondering if i could ask you one more thing.
I was trying to change your code so that I could get it to do the following.
i need to separate the file name eg 50678.cdimage. so that the 50678 goes into one text box and the .cdimage goes into another text box. would you be able to help on this.
Thanks
|
|
|
|
|
Thank you so much. You the man
I'm wondering if i could ask you one more thing.
I was trying to change your code so that I could get it to do the following.
i need to separate the file name eg 50678.cdimage. so that the 50678 goes into one text box and the .cdimage goes into another text box. would you be able to help on this.
Thanks
|
|
|
|