Results 1 to 26 of 26

Thread: Compile errors [resolved]

  1. #1

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Resolved Compile errors [resolved]

    Hi guys

    I have a problem with the string, here is the code:


    Code:
    Sub ReadLanguages()
    Dim Language, caption As String
    Language = ReadIniFile(App.Path & "\LNG.ini", "Language", "Language", "")
    Form1.caption = ReadIniFile(App.Path & "\LNG.ini", "Language", "Title", "")
    
    If Language = "English" Then
       Form1.LANG_English.Checked = True
       Form1.LANG_French.Checked = False
    Dim ctl1 As Control
    
    
    If TypeOf ctl1 Is Menu Then _
    ctl1.caption = ReadIniFile(App.Path & "\EN.ini", "ControlsLanguage", ctl1.Name, "")
    
    Next ctl1
    End If
    
    
    If Language = "French" Then
       Form1.LANG_English.Checked = False
       Form1.LANG_French.Checked = True
    
    
    If TypeOf ct2 Is Menu Then _
    ct2.caption = ReadIniFile(App.Path & "\FR.ini", "ControlsLanguage", ct2.Name, "")
    
    Next ctl2
    End If
    
    End Sub


    I have received the error instruction "Compile error: Next without For". The error instruction tells me the problem with the two following codes "Next ctl1" and "Next ctl2". I have tried everything I can do my best but no luck to refix. What can I do in order to refix??



    Thanks,
    Mark
    Last edited by Mark103; Oct 23rd, 2007 at 11:45 AM.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    Next is used with a For loop.... Your code doesn't really make sense, you declare ctl1 as Control but you never initilize it to anything, which means it points to Nothing. What are you expecting it to do?

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Compile errors

    You also have 4 IF statments and only 2 End If statements.

  4. #4

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Well I am trying to refix the code following on google to exchange it something like this "Next For ctl1". The problem didn't get resolve and I have tried everything as I can! However I don't know what I can do, this is why i am here.




    Hope you can help me with this?

    Thanks,
    Mark

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    What are you expecting it to do?
    Programming code completely aside, what is the anwser to this question?

  6. #6

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Hack
    You also have 4 IF statments and only 2 End If statements.


    Do you know how to refix the problem Hack??

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    Quote Originally Posted by Hack
    You also have 4 IF statments and only 2 End If statements.
    Actually two of the If statements are single lined (well, on two lines but with a line continues character) which doesn't need an End If.

  8. #8

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    Actually two of the If statements are single lined (well, on two lines but with a line continues character) which doesn't need an End If.

    Ok, do I need to remove End If to see if the problem get fix??



    Thanks,
    Mark

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    Try this code:
    vb Code:
    1. Sub ReadLanguages()
    2.     Dim Language As String, sIniFileName As String
    3.     Dim ctl As Control
    4.    
    5.     Language = ReadIniFile(App.Path & "\LNG.ini", "Language", "Language", "")
    6.     Form1.caption = ReadIniFile(App.Path & "\LNG.ini", "Language", "Title", "")
    7.    
    8.     If Language = "English" Then
    9.        Form1.LANG_English.Checked = True
    10.        Form1.LANG_French.Checked = False
    11.        sIniFileName = "\EN.ini"
    12.     Else
    13.        Form1.LANG_English.Checked = False
    14.        Form1.LANG_French.Checked = True
    15.        sIniFileName = "\FR.ini"
    16.     End If
    17.    
    18.     For Each ctl In Form1.Controls
    19.         If TypeOf ctl Is Menu Then
    20.             ctl.caption = ReadIniFile(App.Path & sIniFileName, "ControlsLanguage", ctl.Name, "")
    21.         End If
    22.     Next
    23. End Sub

  10. #10

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Thanks, I have replace it but don't want 'for each ctl in form1.control' because I need the office menu to get respond on the menu.




    Hope you can help


    Thanks,
    Mark
    Last edited by Mark103; Oct 21st, 2007 at 06:16 PM.

  11. #11
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    Hmmm... Did you try my solution? As I understand it you want to translate the Menu items in your Form to either English or French depending on your INI file settings. In that case my code example should work, if you do have the ini files that is...

  12. #12

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    Hmmm... Did you try my solution? As I understand it you want to translate the Menu items in your Form to either English or French depending on your INI file settings. In that case my code example should work, if you do have the ini files that is...

    Yes, I have replaced but don't want 'for each ctl in form1.control' because I need the office menu to get respond on the menu. How can we fix it??



    Mark

  13. #13
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    I still don't understand. Can you please tell us what you want your code to do? What do you mean by "office menu to get respond on the menu"???? Are you using VBA in an Office application like Word or Excel?

  14. #14

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    I still don't understand. Can you please tell us what you want your code to do? What do you mean by "office menu to get respond on the menu"???? Are you using VBA in an Office application like Word or Excel?


    Well, I want my code to translate the menu items at the same time office menu to get work together. The codes you have fixed are working perfectly but they don't get work with the office menu on the menubar for some reasons. I have found a bug that is caused problem:


    Code:
    For Each ctl In Form1.Controls

    I need to have translate on the menu items at the same time that office menu can get working together; I need to have them for my own programming business. And yes I want to use office menu like Word and excel. However I tried to remove the code on above that gave me a problem for office menu; I have received the error and I removed the following code on the bottom:



    Code:
    Next


    I have received another error saying 'Run time error 91: Object variable or With block variable not set' on that following code:



    Code:
            If TypeOf ctl Is Menu Then



    I don't know what I can do to get my own problems fixed.



    I hope there are many other situations that we can find ways to get the problems refixed??


    Thanks,
    Mark
    Last edited by Mark103; Oct 21st, 2007 at 06:50 PM.

  15. #15
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    You can't just remove lines of code and expect it to work. I still don't understand what you're trying to do. The code will iterate through each controls on your Form including menu items, it checks if the control is a menu item and in that case it changes its caption to the text you have in your INI file.

    That is what the code is doing! If you want it to do something else you just need to describe a bit better what that is.

  16. #16

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    You can't just remove lines of code and expect it to work. I still don't understand what you're trying to do. The code will iterate through each controls on your Form including menu items, it checks if the control is a menu item and in that case it changes its caption to the text you have in your INI file.

    That is what the code is doing! If you want it to do something else you just need to describe a bit better what that is.

    Well I am trying to make office menu to get working with language control. But i can still see that they do not work together when I translate to different languages. Maybe you know different way without the needs of language control??


    Thanks,
    Mark

  17. #17
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    What do you mean by "office menu"?

  18. #18

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    What do you mean by "office menu"?

    Office menu like office xp, office 2003. That's what i mean. Hope there's a way of taking over language control??



    Thanks,
    Mark

  19. #19
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    Office is not one application it's a set of different applications. Are you writing this in VBA or are you using VB6? Maybe some screen shots could explain what you're trying to do?

  20. #20

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    Office is not one application it's a set of different applications. Are you writing this in VBA or are you using VB6? Maybe some screen shots could explain what you're trying to do?

    I am using on vb6, the screenshot will tells you the same things what I am trying to do.


    http://img502.imageshack.us/img502/4...expmenuje0.jpg
    http://img136.imageshack.us/img136/4...expmenusd5.jpg


    I am trying to get office xp menu working with language controls when I change to different language. From the start what I can have office xp menu without change of the language. But there will be no office xp menu when I change to different language. Hope this is very clear??



    Thanks,
    Mark
    Last edited by Mark103; Oct 21st, 2007 at 08:13 PM.

  21. #21
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872

    Re: Compile errors

    post your project. Then we can try it ourself.

    Joacims code should work though.
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  22. #22
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    Do you mean that by the press of a menu item in your application all Office applications are translated to a new language????

  23. #23

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    Quote Originally Posted by Joacim Andersson
    Do you mean that by the press of a menu item in your application all Office applications are translated to a new language????

    Yes, this is what I am trying to do to get officemenu working while translated to the new language. Any idea how we can get those working together??




    Hope there is a way to resolve my problem.



    Thanks,
    Mark
    Last edited by Mark103; Oct 22nd, 2007 at 07:08 PM.

  24. #24

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    please anyone?

  25. #25
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compile errors

    I'm not 100% sure, but I don't think you can change the text displayed for a menu item in an office application (if it was why is Microsoft selling localized versions of the Office package?). But please try asking that question in the VBA forum instead. Your original question has been answered and you should mark this thread as resolved.

  26. #26

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Compile errors

    ok, i have done it. Thanks for your advice guys!!!!!!!!!!!





    KEEP UP THE GOOD WORK...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width