7 Replies - 6829 Views - Last Post: 22 May 2013 - 12:11 PM Rate Topic: -----

#1 zaki khan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-May 13

grams to tola masha and ratti conversion

Posted 22 May 2013 - 12:08 AM

i am writing a small piece of code in vb.net which will convert grams to tola masha and ratti respectively.
i can convert grams into number of tolas by number of grams divided by 12.5 but further i am stuck. here are some clues
1 tola = 12 masha
1 masha= 8 ratti
while in grams
1 tola=12.5grams.
Is This A Good Question/Topic? 0
  • +

Replies To: grams to tola masha and ratti conversion

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: grams to tola masha and ratti conversion

Posted 22 May 2013 - 12:18 AM

It just simple maths
If i have 24 masha how many tola is that?
How many ratti do you need to make 1 tola?
Was This Post Helpful? 0
  • +
  • -

#3 x-logan  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 88
  • Joined: 18-April 13

Re: grams to tola masha and ratti conversion

Posted 22 May 2013 - 12:30 AM

Yeah. i Even think this is a simple calculation.

Quote

for tola
suppose
2 tola = 2 *12.5g = 30gram
1gram = (2/30) or (1/12.5) tola

for masha
suppose
1 masha = (1/12)*1*12.5 = approx (1.041)gram
1 gram = (1/1.041)masha

fo ratti

1 ratti = (1/8)*(1/12)*1*12.5 = approx 0.13 gram
or 1 ratti = 1*(1.041/8) = .13 gram
1 gram = (1/.13)ratti

put them in different button click event.

This post has been edited by x-logan: 22 May 2013 - 12:44 AM

Was This Post Helpful? 0
  • +
  • -

#4 zaki khan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-May 13

Re: grams to tola masha and ratti conversion

Posted 22 May 2013 - 01:08 AM

View Postx-logan, on 22 May 2013 - 12:30 AM, said:

Yeah. i Even think this is a simple calculation.

Quote

for tola
suppose
2 tola = 2 *12.5g = 30gram
1gram = (2/30) or (1/12.5) tola

for masha
suppose
1 masha = (1/12)*1*12.5 = approx (1.041)gram
1 gram = (1/1.041)masha

fo ratti

1 ratti = (1/8)*(1/12)*1*12.5 = approx 0.13 gram
or 1 ratti = 1*(1.041/8) = .13 gram
1 gram = (1/.13)ratti

put them in different button click event.

Was This Post Helpful? 0
  • +
  • -

#5 zaki khan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-May 13

Re: grams to tola masha and ratti conversion

Posted 22 May 2013 - 01:14 AM

View Postx-logan, on 22 May 2013 - 12:30 AM, said:

Yeah. i Even think this is a simple calculation.

Quote

for tola
suppose
2 tola = 2 *12.5g = 30gram
1gram = (2/30) or (1/12.5) tola

for masha
suppose
1 masha = (1/12)*1*12.5 = approx (1.041)gram
1 gram = (1/1.041)masha

fo ratti

1 ratti = (1/8)*(1/12)*1*12.5 = approx 0.13 gram
or 1 ratti = 1*(1.041/8) = .13 gram
1 gram = (1/.13)ratti

put them in different button click event.



well i have correct a small mistake in calculation. thanks for the idea. actually i have a text box in which client will input the number of grams. suppose the gold weighs 111 grams. now i want to converts this weight into tola masha and ratti.

for tola: 111\12.5
i will get only the integral part that is 8. means 8 tolas.

for masha and ratti: i have remaining 11 grams now thats what in which i am stuck. i a single click he will know how much tolas mashas and rattis 111gram have.
Was This Post Helpful? 0
  • +
  • -

#6 x-logan  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 88
  • Joined: 18-April 13

Re: grams to tola masha and ratti conversion

Posted 22 May 2013 - 02:38 AM

okay i got you.

take six textboxes and one button. this is simplest way. you can do much better. this is just an idea how calculation goes.
1. for input(grams)
2. for tola
3. for masha
4. for ratti
5. for ist remainder
6. for 2nd remainder

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            TextBox2.Text = Math.Truncate(TextBox1.Text / 12.5) ' this will gives you tola in (textbox2)
            TextBox5.Text = (TextBox1.Text Mod 12.5) ' ist remainder
            TextBox6.Text = (TextBox5.Text Mod 1.0417) ' 2nd remainder
            TextBox3.Text = Math.Truncate(TextBox5.Text / 1.0417) ' this will gives you masha in (textbox3)
            TextBox4.Text = Math.Truncate(TextBox6.Text / 0.13) ' this will gives you masha in (textbox4)
        Catch
        End Try
    End Sub

Was This Post Helpful? 2
  • +
  • -

#7 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: grams to tola masha and ratti conversion

Posted 22 May 2013 - 02:58 AM

maths.truncate will do the Job
The above code working for me.

But I will suggest you to use variables instead of taking too many textboxes. for example textbox5 as A, textbox6 As B,

Dim A, B As Double
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            TextBox2.Text = Math.Truncate(TextBox1.Text / 12.5) ' this will gives you tola in (textbox2)
           
   A = (TextBox1.Text Mod 12.5) ' ist remainder
   B = (A Mod 1.0417) ' 2nd remainder

   TextBox3.Text = Math.Truncate(A / 1.0417) ' this will gives you masha in (textbox3)
   TextBox4.Text = Math.Truncate(B / 0.13) ' this will gives you Ratti in (textbox4)

       Catch
        End Try

This post has been edited by kai_itz me: 22 May 2013 - 03:21 AM

Was This Post Helpful? 1
  • +
  • -

#8 zaki khan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-May 13

Re: grams to tola masha and ratti conversion

Posted 22 May 2013 - 12:11 PM

thank u so much guys. that work like charm.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1