By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

convert codes....

P: 4
hallo...can i get some knowladge...about java script convert to V.B....how??like 'calculation downloadable',i've get a formula calculate but in java script....how i want convert this language to V.B

This is formula in java script:

<script language="JavaScript">
<!--
var gaji;
var cpekerja;
var cmajikan;
var semua;
var pilih;

function kira(form) {
pilih = form.pilihan.options[form.pilihan.selectedIndex].value;
gaji = form.gaji.value;

if (pilih == '' || gaji == '' || gaji == '0' || gaji == '0.00' || gaji == '0.0') {
alert('Please select year and your annual income for that year.'); } else { if (pilih == '1') {
cpekerja=5;
cmajikan=5;
form.cpekerja.value=cpekerja;
form.cmajikan.value=cmajikan;
} else if (pilih == '3') {
cpekerja=6;
cmajikan=7;
form.cpekerja.value=cpekerja;
form.cmajikan.value=cmajikan;
} else if (pilih == '4') {
cpekerja=9;
cmajikan=11;
form.cpekerja.value=cpekerja;
form.cmajikan.value=cmajikan;
} else if (pilih == '5') {
cpekerja=10;
cmajikan=12;
form.cpekerja.value=cpekerja;
form.cmajikan.value=cmajikan;
} else if (pilih=='6') {
cpekerja=11;
cmajikan=12;
form.cpekerja.value=cpekerja;
form.cmajikan.value=cmajikan;
} if (pilih=='7') {
cpekerja=9;
cmajikan=12;
form.cpekerja.value=cpekerja;
form.cmajikan.value=cmajikan;
}
cpekerja = (cpekerja*gaji)/100;
form.total.value = cpekerja

cmajikan = (cmajikan*gaji)/100;
form.total.value = cmajikan

cpekerja = eval(cpekerja);
cmajikan = eval(cmajikan);
semua = cpekerja + cmajikan;
form.total.value=Math.round(semua*100)/100;
}
}

//-->
</script>
Nov 28 '06 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2.     <!--
  3.     var gaji;
  4.     var cpekerja;
  5.     var cmajikan;
  6.     var semua;
  7.     var pilih;
  8.  
  9.     function kira(form) {
  10.         pilih = form.pilihan.options[form.pilihan.selectedIndex].value;
  11.         gaji = form.gaji.value;
  12.  
  13.         if (pilih == '' || gaji == '' || gaji == '0' || gaji == '0.00' || gaji == '0.0') {
  14.             alert('Please select year and your annual income for that year.'); } else { if (pilih == '1') {
  15.                 cpekerja=5;
  16.                 cmajikan=5;
  17.                 form.cpekerja.value=cpekerja;
  18.                 form.cmajikan.value=cmajikan;
  19.             } else if (pilih == '3') {
  20.                 cpekerja=6;
  21.                 cmajikan=7;
  22.                 form.cpekerja.value=cpekerja;
  23.                 form.cmajikan.value=cmajikan;
  24.             } else if (pilih == '4') {
  25.                 cpekerja=9;
  26.                 cmajikan=11;
  27.                 form.cpekerja.value=cpekerja;
  28.                 form.cmajikan.value=cmajikan;
  29.             } else if (pilih == '5') {
  30.                 cpekerja=10;
  31.                 cmajikan=12;
  32.                 form.cpekerja.value=cpekerja;
  33.                 form.cmajikan.value=cmajikan;
  34.             } else if (pilih=='6') {
  35.                 cpekerja=11;
  36.                 cmajikan=12;
  37.                 form.cpekerja.value=cpekerja;
  38.                 form.cmajikan.value=cmajikan;
  39.             } if (pilih=='7') {
  40.                 cpekerja=9;
  41.                 cmajikan=12;
  42.                 form.cpekerja.value=cpekerja;
  43.                 form.cmajikan.value=cmajikan;
  44.             }
  45.             cpekerja = (cpekerja*gaji)/100;
  46.             form.total.value = cpekerja
  47.  
  48.             cmajikan = (cmajikan*gaji)/100;
  49.             form.total.value = cmajikan
  50.  
  51.             cpekerja = eval(cpekerja);
  52.             cmajikan = eval(cmajikan);
  53.             semua = cpekerja + cmajikan;
  54.             form.total.value=Math.round(semua*100)/100;
  55.         }
  56.     }
  57.  
  58.     //-->
  59.     </script>
First, a question. I realise that I'm dealing with a somewhat unfamiliar language. But surely setting the same variable (or control) three times (as highlighted above) would not serve much purpose? And what is the significance of the missing semicolons on these lines?

Anyway, here's my first draft...
Expand|Select|Wrap|Line Numbers
  1. Public Sub kira(frm As Form)
  2.  
  3.   Dim gaji, cpekerja, cmajikan, semua, pilih
  4.  
  5.  
  6. ' Sorry, I don't know how to translate this line...
  7. '  pilih = frm.pilihan.options[form.pilihan.selectedIndex].value;
  8.  
  9. ' This depends on the type of control. If it's a textbox for example, you'd want .Text rather than .value
  10.    gaji = frm.gaji.value
  11.  
  12.   If pilih = "" or gaji = "" or gaji = "0" or gaji = "0.00' or gaji = "0.0" Then
  13.     MessageBox "Please select year and your annual income for that year."
  14.     Exit Sub
  15.   End If
  16.  
  17.   Select case pilih
  18.     Case "1"
  19.      cpekerja = 5
  20.      cmajikan = 5
  21.      frm.cpekerja = cpekerja
  22.      frm.cmajikan = cmajikan
  23. ' How come there's no 2?
  24.     Case "3"
  25.      cpekerja = 6
  26.      cmajikan = 7
  27.      frm.cpekerja = cpekerja
  28.      frm.cmajikan = cmajikan
  29.     Case "4"
  30.      cpekerja = 9
  31.      cmajikan = 11
  32.      frm.cpekerja = cpekerja
  33.      frm.cmajikan = cmajikan
  34.     Case "5"
  35.      cpekerja = 10
  36.      cmajikan = 12
  37.      frm.cpekerja = cpekerja
  38.      frm.cmajikan = cmajikan
  39.     Case "6"
  40.      cpekerja = 11
  41.      cmajikan = 12
  42.      frm.cpekerja = cpekerja
  43.      frm.cmajikan = cmajikan
  44.     Case "7"
  45.      cpekerja = 9
  46.      cmajikan = 12
  47.      frm.cpekerja = cpekerja
  48.      frm.cmajikan = cmajikan
  49.   End Select
  50.  
  51.  
  52.   cpekerja = (cpekerja*gaji)/100;
  53.   frm.total = cpekerja
  54.  
  55.   cmajikan = (cmajikan*gaji)/100;
  56.   frm.total = cmajikan
  57.  
  58. '  cpekerja = eval(cpekerja);   What does this do?
  59. '  cmajikan = eval(cmajikan);   What does this do?
  60.   semua = cpekerja + cmajikan;
  61.   frm.total=(semua*100)/100
  62. End Sub
Nov 28 '06 #2

sashi
Expert 100+
P: 1,754
First, a question. I realise that I'm dealing with a somewhat unfamiliar language. But surely setting the same variable (or control) three times (as highlighted above) would not serve much purpose? And what is the significance of the missing semicolons on these lines?

Anyway, here's my first draft...
Expand|Select|Wrap|Line Numbers
  1. Public Sub kira(frm As Form)
  2.  
  3.   Dim gaji, cpekerja, cmajikan, semua, pilih
  4.  
  5.  
  6. ' Sorry, I don't know how to translate this line...
  7. '  pilih = frm.pilihan.options[form.pilihan.selectedIndex].value;
  8.  
  9. ' This depends on the type of control. If it's a textbox for example, you'd want .Text rather than .value
  10.    gaji = frm.gaji.value
  11.  
  12.   If pilih = "" or gaji = "" or gaji = "0" or gaji = "0.00' or gaji = "0.0" Then
  13.     MessageBox "Please select year and your annual income for that year."
  14.     Exit Sub
  15.   End If
  16.  
  17.   Select case pilih
  18.     Case "1"
  19.      cpekerja = 5
  20.      cmajikan = 5
  21.      frm.cpekerja = cpekerja
  22.      frm.cmajikan = cmajikan
  23. ' How come there's no 2?
  24.     Case "3"
  25.      cpekerja = 6
  26.      cmajikan = 7
  27.      frm.cpekerja = cpekerja
  28.      frm.cmajikan = cmajikan
  29.     Case "4"
  30.      cpekerja = 9
  31.      cmajikan = 11
  32.      frm.cpekerja = cpekerja
  33.      frm.cmajikan = cmajikan
  34.     Case "5"
  35.      cpekerja = 10
  36.      cmajikan = 12
  37.      frm.cpekerja = cpekerja
  38.      frm.cmajikan = cmajikan
  39.     Case "6"
  40.      cpekerja = 11
  41.      cmajikan = 12
  42.      frm.cpekerja = cpekerja
  43.      frm.cmajikan = cmajikan
  44.     Case "7"
  45.      cpekerja = 9
  46.      cmajikan = 12
  47.      frm.cpekerja = cpekerja
  48.      frm.cmajikan = cmajikan
  49.   End Select
  50.  
  51.  
  52.   cpekerja = (cpekerja*gaji)/100;
  53.   frm.total = cpekerja
  54.  
  55.   cmajikan = (cmajikan*gaji)/100;
  56.   frm.total = cmajikan
  57.  
  58. '  cpekerja = eval(cpekerja);   What does this do?
  59. '  cmajikan = eval(cmajikan);   What does this do?
  60.   semua = cpekerja + cmajikan;
  61.   frm.total=(semua*100)/100
  62. End Sub
Hi Killer,

It's Bahasa Melayu (Malay Language), i think he is a Malaysian. :)
Nov 28 '06 #3

Expert 5K+
P: 8,434
It's Bahasa Melayu (Malay Language), i think he is a Malaysian. :)
Thanks sashi. But I was referring to the javascript.
Nov 28 '06 #4

Expert 5K+
P: 8,434
...
Expand|Select|Wrap|Line Numbers
  1. ...
  2.   cpekerja = (cpekerja*gaji)/100;
  3. ...
  4.   cmajikan = (cmajikan*gaji)/100;
  5.  
Sorry, I forgot to remove the semicolons from these two lines. VB probably won't like them.
Nov 28 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.