We help IT Professionals succeed at work.

Question on tabs in VB.

akohan
akohan asked
on
175 Views
Last Modified: 2013-12-26
Hello group,

I have two tabs on a form. in one tab user can enter infomation and in
the other tab there is a button which allows user to
check a log file contents. In fact, by clicking the button
a small form opens up and shows a the contents of a text or log file.

Now, I found that when user enters information and switches to the 2nd tab and clicks the button to look at the log file
as soon as the small form gets closed the contents of the entry in the first tab
get clear!!!

how does this happen? and how can I fix it?

Regards,
amit
Comment
Watch Question

Commented:
hello akohan,

it's not a known situation, it's likely related with your code, can you give the full code related with the action?

Commented:
perhaps, when the form closes, you may be doing something like closing/opening the first form. do you have a code which sets that textbox = "" in anywhere of your application? this may be getting fired by mistake perhaps?

Commented:
to debug it you can do the following;

in the ide, debug menu > add watch

choose (all procedures)
choose your form in the modules box.

expression box > type myTextBox.text which myTextBox is your textbox name

choose break when value changes

click ok

start the program

whenever the textbox text changes the program will pause. if it's not where you want (eg textbox is first initialized etc.) just hit the continue button.

when it's the problem part (textbox gets cleaned unintentionally) you'll see the code which caused the change. if you want to see what called that code, press ( ctrl - l ) keys to see the caller history.

this way you can find out what causes the problem.

Author

Commented:


Hello,

One of the major problems of VB is since I'm developing a COM server (dll) the debug doesn't work at all !!! because as soon as I get to debug mode all my custom menu in Excel get hidden so I won't be able to trace anything.

I'll send you my code.

Thanks.

Author

Commented:

Hi again,

As soon as it unloads the ViewLog form it clears the editbox contents when this code gets triggered:


Private Sub BtnCloseLogView_Click()

    On Error GoTo BtnCloseLogViewErrHandler
   
    Unload Me
   
    Exit Sub
   
BtnCloseLogViewErrHandler:
   
    ExcelApp.Cursor = xlNorthwestArrow
   
    Dim oFile As CFileIO
    Set oFile = New CFileIO
   
    Dim strMsg As String
    strMsg = Err.Description & SEPARATOR & Err.Number
   
    oFile.LogInformation (vbLf & "***Error (BtnCloseLogView click event): " & Now & SEPARATOR & strMsg)
   
    If bLanguage = False Then
       
        MsgBox strMsg, vbCritical, LoadResString(resCritic)
    Else
   
        MsgBox strMsg, vbCritical, LoadResString(resCritic + 100)
       
    End If
   
   
    Err.Clear
    Set oFile = Nothing
   
End Sub

Commented:
there is nothing wrong with this code. so how do you show the form? modal or modeless?

if it's modal, try putting something right after the .show in the caller procedure to test if the box gets cleared right after the form unload or later. like

show xxxxxxxx
msgbox myTextBox.text

Author

Commented:


Thanks I did and the text still is there but as soon as I close it, it disappeasrs!

Any advice?

Thanks,
ak

Commented:
So you show the form as a modal form? Can you send the code which shows up the form?

I would go up putting assertions step by step. When I realize that it's not about the code which shows the form, I would try key events like form.initialize, form.load etc.

Author

Commented:

Hi MrRobot,

Sorry for the delay. Yes it is modal. here is the code:

Private Sub BtnViewLog_Click()
   
    On Error GoTo BtnViewLog_ClickErrHandler
   
    frmLogView.Show vbModal
   
   
    Exit Sub
   
BtnViewLog_ClickErrHandler:
   
   
    ExcelApp.Cursor = xlNorthwestArrow
    Dim oFile As CFileIO
    Dim strMsg As String
   
    Set oFile = New CFileIO
       
    strMsg = Err.Description & SEPARATOR & Err.Number

    oFile.LogInformation (vbCr & "***Error (BtnViewLog_Click()): " & strMsg)
   
    If bLanguage = False Then
   
        MsgBox strMsg, vbCritical, LoadResString(resCritic)
       
    Else
   
        MsgBox strMsg, vbCritical, LoadResString(resCritic + 100)
       
    End If
   
    Set oFile = Nothing
    Err.Clear
   
End Sub

Author

Commented:


I'm not that good at triggers/events relation of control in VB but I was thinking maybe when I close the dialog or form something gets triggered in Active_  or Form_Load of the main form. Is this possible?

Regards,
ak
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.