• Print

Author Topic: help coding  (Read 105 times)

23452

  • Jr. Member
  • **
  • Posts: 72
    • Email
help coding
« on: November 04, 2012, 09:07:29 PM »
I came up with a idea that SHOULD be able to solve strings with (), systems and even squares not in stranded form by converting a old code for a calculator in vb that I made I while back.

However it uses many commands that I don't how to use in qb, so could you guys help with the coding.

First it needs to read the  length of the string and store it as a integer(TL)

Then it needs to read each  character until it reaches the "=" counting  how many characters it was from the start(left to right) and saving is as integer(LL).

Then it needs to split the equation into to two(eL and eR) by making eL = to the characters 0 to LL-1, and eR to LL to TL.

It needs to check for () this is the tricky part. It needs to read the equation for ( and if it finds one it needs to save the character it is at and then start reading backwards(right to left) until it hits a /,+,-, or *; if it reads a x then Bc = true, if it reads a x^2 then Ac = true, if it is not a x then convert the charter to a value and store in cholder( number of charters counted back from "(" ) . Now that we have the number to multiple the () by we need to split the hath of the equation. Set po to 1 and start reading the charters for "(" and ")"; each time it comes to a "(" po=po+1 and for every ")" pc=pc+1 until po=pc. Since we now know where the () open and close we can split that hath of the equation into two(be sure to take the charters in cholder out of the starting equation and save it). THIS NEED TO BE IN A SUB OR FULTON.


Please help with any part if you can; no hard feelings if you don't want to personally the () part looks like a nightmare to code.

If anyone thinks that I trying to dump the work off on other, this is not even hath the code and I spent hours coming up with this and working though it on paper.   







 



 

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2264
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: help coding
« Reply #1 on: November 04, 2012, 09:18:07 PM »
Quote from: 23452 on November 04, 2012, 09:07:29 PM
I came up with a idea that SHOULD be able to solve strings with (), systems and even squares not in stranded form by converting a old code for a calculator in vb that I made I while back.

However it uses many commands that I don't how to use in qb, so could you guys help with the coding.

First it needs to read the  length of the string and store it as a integer(TL)

TL = LEN(math$)

Then it needs to read each  character until it reaches the "=" counting  how many characters it was from the start(left to right) and saving is as integer(LL).

LL = INSTR(math$, "=")

Then it needs to split the equation into to two(eL and eR) by making eL = to the characters 0 to LL-1, and eR to LL to TL.

eL$ = LEFT$(math$, LL -1)
eR$ = RIGHT$(math$, TL - LL)


It needs to check for () this is the tricky part. It needs to read the equation for ( and if it finds one it needs to save the character it is at and then start reading backwards(right to left) until it hits a /,+,-, or *; if it reads a x then Bc = true, if it reads a x^2 then Ac = true, if it is not a x then convert the charter to a value and store in cholder( number of charters counted back from "(" ) . Now that we have the number to multiple the () by we need to split the hath of the equation. Set po to 1 and start reading the charters for "(" and ")"; each time it comes to a "(" po=po+1 and for every ")" pc=pc+1 until po=pc. Since we now know where the () open and close we can split that hath of the equation into two(be sure to take the charters in cholder out of the starting equation and save it). THIS NEED TO BE IN A SUB OR FULTON.

It's late, but these can be done with combinations of INSTR, LEFT$, RIGHT$, MID$ rather easily.

Please help with any part if you can; no hard feelings if you don't want to personally the () part looks like a nightmare to code.

If anyone thinks that I trying to dump the work off on other, this is not even hath the code and I spent hours coming up with this and working though it on paper.   







 



 

23452

  • Jr. Member
  • **
  • Posts: 72
    • Email
Re: help coding
« Reply #2 on: November 06, 2012, 04:53:41 PM »
Think you so much. I though I was going to have to do it all with mid$

  • Print