evaluating variables with specific order?

I'm new to VS C# express edition, coming from foxpro for windows.

in Foxpro I can write (silly example ):

for i=1 to 5

ii=str(i,1)

offer&ii=i*5

next

for i=1 to 5

ii=str(i,1)

mod(offer&ii,2)

next

How you do this in C# Any suggestion please!

Thanks,

danny



Answer this question

evaluating variables with specific order?

  • DeepaHadimani

    If you need five variables, you create an array. int [] i = new int [5]; Then you have i[0], i[1], ... i[4] ( it's zero indexed ). Is that what you're after

  • rp0513

    What does offer & ii do in FoxPro In C#, it does a bitwise and on the two values, and returns a value, which you can't then change without first naming it something.

    The Math namespace contains static methods such as Mod.



  • vkumarme

    You can name the textboxes and search through the controls collection for them. You can also add all your textboxes to a typed array, and loop through them that way. I don't see how an unsafe block would help.

    You cannot tie text boxes together in the manner that you're hoping. There is a TextChanged event on the text box, but you'd have to write a fair bit of code to plumb all this together.

    The other way is to create an array, and a method which moves values from the array into the text boxes. Then you can change the array, and call your method as needed.



  • Robert Jackson

    For example :

    I made 65 textBox (Financial/Investment program), I need them to display :

    textBox1=5, textBox2=10, textBox3=15, and so on until textBox65. (each textbox value=textBox"Number"*5.

    in C# I have to write :

    for (i=1; i<66;i++)

    {

    int result=i*5

    textBox1.Text=result.toString()  ----It doesn't change to textBox 2 or 3 automatically.

    }

    But I cant, because I cant change the textBox numbering. Is there any other way to do it

    I read something about unary/unsafe, but not sure. besides the word unsafe scares me. :(

    Thanks

    danny

     


  • The.B

    Thanks cgraus for the reply! :)

    it creates 5 variables(int) containing numbers :

    offer1=5

    offfer2=10

    offer3=15 etc.

    then it prints the result of MOD() for offer1 to offer5 :

    1      ---displayed on screen etc

    0

    1

    0

    1  -- offer5

    - I need to do a same calculation without having to write the similar variables again and again. Sorry I used a silly example. Really need help on this.

    thanks

    danny

     


  • ChiefGeek

    Thanks cgraus for your suggestions. greatly appreciate it! :)

    I will look into it, thanks again


  • evaluating variables with specific order?