|
-
Oct 21st, 2007, 05:40 PM
#1
Thread Starter
Banned
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.
-
Oct 21st, 2007, 05:44 PM
#2
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?
-
Oct 21st, 2007, 05:49 PM
#3
Re: Compile errors
You also have 4 IF statments and only 2 End If statements.
-
Oct 21st, 2007, 05:50 PM
#4
Thread Starter
Banned
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
-
Oct 21st, 2007, 05:54 PM
#5
Re: Compile errors
 Originally Posted by Joacim Andersson
What are you expecting it to do?
Programming code completely aside, what is the anwser to this question?
-
Oct 21st, 2007, 06:01 PM
#6
Thread Starter
Banned
Re: Compile errors
 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??
-
Oct 21st, 2007, 06:02 PM
#7
Re: Compile errors
 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.
-
Oct 21st, 2007, 06:03 PM
#8
Thread Starter
Banned
Re: Compile errors
 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
-
Oct 21st, 2007, 06:08 PM
#9
Re: Compile errors
Try this code:
vb Code:
Sub ReadLanguages()
Dim Language As String, sIniFileName As String
Dim ctl As Control
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
sIniFileName = "\EN.ini"
Else
Form1.LANG_English.Checked = False
Form1.LANG_French.Checked = True
sIniFileName = "\FR.ini"
End If
For Each ctl In Form1.Controls
If TypeOf ctl Is Menu Then
ctl.caption = ReadIniFile(App.Path & sIniFileName, "ControlsLanguage", ctl.Name, "")
End If
Next
End Sub
-
Oct 21st, 2007, 06:10 PM
#10
Thread Starter
Banned
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.
-
Oct 21st, 2007, 06:14 PM
#11
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...
-
Oct 21st, 2007, 06:16 PM
#12
Thread Starter
Banned
Re: Compile errors
 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
-
Oct 21st, 2007, 06:22 PM
#13
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?
-
Oct 21st, 2007, 06:46 PM
#14
Thread Starter
Banned
Re: Compile errors
 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:
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.
-
Oct 21st, 2007, 07:13 PM
#15
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.
-
Oct 21st, 2007, 07:37 PM
#16
Thread Starter
Banned
Re: Compile errors
 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
-
Oct 21st, 2007, 07:38 PM
#17
Re: Compile errors
What do you mean by "office menu"?
-
Oct 21st, 2007, 07:44 PM
#18
Thread Starter
Banned
Re: Compile errors
 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
-
Oct 21st, 2007, 07:47 PM
#19
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?
-
Oct 21st, 2007, 08:10 PM
#20
Thread Starter
Banned
Re: Compile errors
 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.
-
Oct 22nd, 2007, 09:54 AM
#21
Fanatic Member
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.
-
Oct 22nd, 2007, 10:57 AM
#22
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????
-
Oct 22nd, 2007, 11:28 AM
#23
Thread Starter
Banned
Re: Compile errors
 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.
-
Oct 23rd, 2007, 09:34 AM
#24
Thread Starter
Banned
-
Oct 23rd, 2007, 10:07 AM
#25
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.
-
Oct 23rd, 2007, 11:05 AM
#26
Thread Starter
Banned
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|