• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

Question on tabs in VB.

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
0
akohan
Asked:
akohan
  • 6
  • 5
1 Solution
 
MrRobotCommented:
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?
0
 
MrRobotCommented:
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?
0
 
MrRobotCommented:
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.

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
akohanAuthor 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.
0
 
akohanAuthor 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
0
 
MrRobotCommented:
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
0
 
akohanAuthor Commented:


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

Any advice?

Thanks,
ak

0
 
MrRobotCommented:
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.

0
 
akohanAuthor 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
0
 
akohanAuthor 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
0
 
MrRobotCommented:
hi akohan,

since it's a modal call, it's barely possible to re-initiate a new instance of the first form by mistake.
this piece also looks ok. so the next step would be testing when the text is cleared. right after the .show call, use something like;

msgbox "1 " & myTextBox.text

and on form load,

msgbox "2 " & myTextBox.text

and so on the other suspected events. this will help you determine where exactly the contents get cleared.

Nothing in your code seems to be wrong so far. Do you pass any info across the forms, or the second form does its thing independently?

Actually, it would be much easier if you could do a debug, dunno the problem in your case, but you should be able to debug a com server running in excel.

I suggest you check this topic for debugging a com server;
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_11344577.html?sfQueryTermInfo=1+com+debug

Also this will make it easier to work with excel in a debug session;
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_22617203.html?sfQueryTermInfo=1+com+debug

Hope this will help =)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now