[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Question on tabs in VB.

Posted on 2007-10-12
11
Medium Priority
?
161 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
0
Comment
Question by:akohan
  • 6
  • 5
11 Comments
 
LVL 8

Expert Comment

by:MrRobot
ID: 20068678
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
 
LVL 8

Expert Comment

by:MrRobot
ID: 20068712
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
 
LVL 8

Expert Comment

by:MrRobot
ID: 20068834
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:akohan
ID: 20068882


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
 

Author Comment

by:akohan
ID: 20069007

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
 
LVL 8

Expert Comment

by:MrRobot
ID: 20069381
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
 

Author Comment

by:akohan
ID: 20069622


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

Any advice?

Thanks,
ak

0
 
LVL 8

Expert Comment

by:MrRobot
ID: 20069929
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
 

Author Comment

by:akohan
ID: 20095167

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
 

Author Comment

by:akohan
ID: 20095183


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
 
LVL 8

Accepted Solution

by:
MrRobot earned 1500 total points
ID: 20097571
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question