|
Hi, I created a .dll that contains various forms I wish to keep outside the main .exe
This Sub in my .exe's main form calls: Show_Form1()
Private Sub Show_ThisForm(ByVal sender As Object, ByVal e As EventArgs)
ThisForm.Show_Form1()
End Sub
WHERE .dll's code is:
Public sub Show_Form1()
Dim ThisForm as new Form1
Form1.ShowDialog()
End sub
Form1's Load Sub is this:
Private Sub Base_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Text &= "please, wait..."
Show()
Refresh()
Cursor = Cursors.WaitCursor
If Con.State <> 1 Then
MsgBox("The Server is not available", MsgBoxStyle.Critical, "Cannot Proceede")
Close()
Else
Try
Retry:
myClient.DownloadFile("http://www.site.com/", ResFile)
If Init_Parser() = True Then
Text = "Ready!!!"
Get_Info()
Else
Close()
End If
Catch
If MsgBox(Err.Description & Chr(10) & "Would you like to try again?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Connection failed") = MsgBoxResult.Yes Then
GoTo Retry
Else
Close()
End If
End Try
Cursor = Cursors.Default
End If
End Sub
Now, here is the THING: If (myClient.DownloadFile) succedes everything goes just fine, but if it fails then my .exe's main form minimizes and the programe start using all CPU power(will not release it)
If I press (pause) to debug, it stops at this line (***)
Public sub Show_Form1()
Dim ThisForm as new Form1
Form1.ShowDialog() (***)
End sub
I have no idea what's going on, can anybody help?, please!!!
In theory, Form1 should close and the .exe's main form should regain focus
-- modified at 0:07 Monday 17th April, 2006
|
|
|
|
|
You've created an endless loop with the combination of structured exeption handling (SEH = Try...Catch) and the GoTo Retry statement. You really should not use GoTo especially when you redirect the code back into the Try block.
Restructure the code and see how you go.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
First of all, Thank you for your help. I just noticed that I did not explain the issue properly.
When myClient.DownloadFile fails, the execution goes into the CATCH statement, and asks the user if he wishes to try again. The problem occurs when the user press's NO; if so, the only line of code that is executed is:
Close().
skiping the GoTo statement.
The entire Base_Load sub completes (I could not detect the the endless loop, but, if this was the case, the execution would reamin between the Retry and the GoTo statements. is this not right?). Since both the .dll project and the main app belong to the same solution, I can debug both projects simultaneously; if a endless loop were created the debuger would pause(on my request)execution in any of the lines in between the loop(**)
Try
Retry: '(**)
myClient.DownloadFile("http://www.site.com/", ResFile)
If Init_Parser() = True Then
Text = "Ready!!!"
Get_Info()
Else
Close()
End If
Catch
If MsgBox(Err.Description & Chr(10) & "Would you like to try again?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Connection failed") = MsgBoxResult.Yes Then
GoTo Retry '(**)
Else
Close()
End If
End Try
instead of in the .exe's main form line: (***)
Public sub Show_Form1()
Dim ThisForm as new Form1
Form1.ShowDialog() (***)
End sub
Please, do not missunderstand me, I am not, by any means, proud of my "code", nor refusing to modify it. I am trying to understand what the problem is so that it would not bit me again
By the way, the only reason why a I using .ShowDialog instead of .Show is because the user must resolve that dialog in order to continue working with the .exe (is this approach wrong?)
Once again, thanks a lot for helping me learn how to Fish your are very kind.
|
|
|
|
|
You've still created an endless loop in your Try/Catch with no hope of ever stopping it if the error condition persists indefinitly. Restrcuture it so it only tries for a limited TIME or a set number of ATTEMPTS before completely giving up. And don't EVER use GOTO's. It's just not necessary.
While Attempting = True
Try
' yada, yada, yada
Catch
' yada, yada, yada
End Try
If successful Then
' return to caller
Else
update 'Attempting' tracker
EndIf
End While
' If we get here, the process has failed repeatedly and we've given up...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
does anyone know how to create custom project wizards for Ms vb 2005 express edition? i searched the web for a little while with no success. i found how to do it in c# here[^] but cannot convert the code to vb.net.
any help is greatly apprectiated.
- Kyle
|
|
|
|
|
The following code is a VB6 Standard EXE. I create an Excel app using OLE Automation. I only want One Excel app to be opened at one time. If the Excel app is already opened, I reuse it to update the cell value.
If the user close the Excel and re-click the Command1 button in the VB app, the app should create a fresh excel app. However, the code below show runtime error. How to check whether the user have close the Excel app created by VB? Please advise... Thanks.
---------------------- The Code -----------------------
Option Explicit
Dim myApp As Excel.Application
Private Sub Command1_Click()
If myApp Is Nothing Then
Set myApp = New Excel.Application
myApp.Workbooks.Add
myApp.Visible = True
End If
myApp.Cells(1, 1).Value = "Hello"
End Sub
Pedestrian
|
|
|
|
|
You can avoid the runtime error by using this.
Dim myApp As Excel.Application<br />
Private Sub Button1_Click()<br />
myApp.Workbooks.Add()<br />
myApp.Visible = True<br />
myApp.Cells(1, 1).Value = "Hello"<br />
End Sub
I have no idea, how to check whether the user has close the Excel app.
I’ll be back n 12 hours
Regards,
Chatura Dilan
|
|
|
|
|
Thanks... I have found the solution, just check for Visible property of myApp object solve the error...
Regards,
Pedestrian
|
|
|
|
|
Just wanna know if vb ver 5.0 is compatible with windows xp and wher can i get the relevant information?
I would like to know whether VB 5.0 is compatible with Windows XP and wher can i get the relevant information?
|
|
|
|
|
Yes, VB6 apps will work on XP, so long as the VB6 Runtime is installed. THe problem you have with getting information is VB5 hasn't been around for about, oh..., 10 years or so.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
So wad are the codin for the vb 5 in wins xp,as currently the codin i have for copyin of files sometimes does not work in wins xp. So is there any specified code for the transfer files in vb 5 if we use wins xp?
I would like to know whether VB 5.0 is compatible with Windows XP and wher can i get the relevant information?
-- modified at 23:11 Sunday 16th April, 2006
|
|
|
|
|
claiborne wrote: So wad are the codin for the vb 5 in wins xp
What???? There is no "code for XP". You code for your application!
claiborne wrote: currently the codin i have for copyin of files sometimes does not work in wins xp
This would be a problem in your code or the understanding of filesystems, whether networked or not.
claiborne wrote: So is there any specified code for the transfer files in vb 5 if we use wins xp
No.
claiborne wrote: I would like to know whether VB 5.0 is compatible with Windows XP and wher can i get the relevant information?
I already told you... And in case you haven't figured it out yet, there is no site or information specific to running VB5 apps on Windows XP. VB5 died about 10 years ago!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
So wad are the codin for the vb 5 in wins xp,as currently the codin i have for copyin of files sometimes does not work in wins xp. So is there any specified code for the transfer files in vb 5 if we use wins xp?
I would like to know whether VB 5.0 is compatible with Windows XP and wher can i get the relevant information?
|
|
|
|
|
Dave has given you the answer. Now it is your turn to get off your a** and do some research. Maybe you could visit www.microsoft.com as a start. Also msdn.microsoft.com has a FREE download of Visual Studio Express so that you can code in a more modern environment. VB5 is dead. Live with it.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
how i can get value of callerid by using SerialPort
vb.net 2005
please i need to a sample code
123
|
|
|
|
|
First, you need a modem, or some other device, that will actually return the CallerID information. Then it's a simple matter of using the SerialPort class to talk to your device. You might have to issue commands to the device to configure it to give you the information you want, but this would be covered in the devices documentation. You'll have to set the proper speed, bits, and parity to talk to the device first though.
Documentation on the SerialPost class[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i'm using vb.net 2005
how i can add a button to datagridviewcolumnTextbox
123
|
|
|
|
|
Hey, I'm new in VB.NET and in my application I'm writing, I would like to save a timestamp (current date and time) in my Access-db. But I can't really figure out how to do it. Can someone help me with this?
Your help is much appreciated!!
Thanks,
G72360
|
|
|
|
|
Timestamps?? Are you looking to timestamp each record in a table during an update or insert? Easy enough. Just add a DateTtime field to the table. When you do your SQL UPDATE or INSERT commands, supply the current Date and Time as a parameter to the SQL statement in that field you added.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am deploying my window application but after the successful installation of the application the exe is not comming into the start menu ---- programs
Please help me
|
|
|
|
|
Will you please stop spamming the forum?
If you don't get an answer within a reasonable time then no one can/will help you. Posting the same question over and over in all forums does not guarantee you an answer. It only pisses off the forum members.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
-- modified at 19:50 Sunday 16th April, 2006
|
|
|
|
|
....besides, you were given the answer here to your ORIGINAL question[^]
Learn to read and use the forums wisely.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
How to get the user screen resolution?
What I mean is 800*600, 1024*768 ...
Thank you!!!
|
|
|
|
|
Please write a descriptive subject.
Are you using VB or VB.NET?
Do you want the physical screen resoultion or the screen area available for programs (e.g. excluding the taskbar)?
Do you want the current screen for an application, the resolution of all screens, or the size of the desktop? There can theoretically be any number of screens connected to the computer. For an example; I have currently two screens, one 1900x1200 and one 1600x1200, forming a rectangular desktop area of 3500x1200.
---
b { font-weight: normal; }
|
|
|
|