hi friends can you help me on these 2 problems

Discussion in 'Questions (Windows Mobile)' started by o2flameuser, May 22, 2009.

  1. o2flameuser

    o2flameuser Member

    1 ) think about 3 textbox
    i wanna to make
    when i enter first textbox a number and to a second a number
    for example 3 and 5 after i wanna to add these number automatically by without pressing a button and program put to the third textbox 8
    txb1 3
    txb2 5
    result txb3 8
    how is this possible ?

    2) i save data s from my program to a word file for example logs.txt
    with
    fileopen(c1,"logs.txt",cwrite)
    filewrite(c1,textbox1.text) which is going to save the text that what i enter to it

    actually the problem is when i to try open that logs.txt while running the program device gives errors

    but when i open the logs.txt after exit my program it opens it and i can see the contents

    but i wanna to open it while program is running with a shell command

    how is possible ?
     
  2. Cableguy

    Cableguy Expert Licensed User

    use the Key Press event...
    From the help file:
    Wich mean that on this event, you can check if the textbox value is valid or not, and then execute some other thing..
     
  3. o2flameuser

    o2flameuser Member

    for example can you give me an axample please ?
     
  4. Cableguy

    Cableguy Expert Licensed User

    The best event to use would be the OnTxtChanged event, but it is only available on ControlsEx from Agraham...
    This is untested code and may not even work, but should give you an idea....

    Sub TextBox1_KeyPress (SpecialKey) This is the key(s) you want to test
    Textbox3.text=Textbox1.text+textbox2.text
    End sub
     
  5. o2flameuser

    o2flameuser Member

    my friend it is givin an error when i try to enter eny value for textbox1
    the error as follows
    An error occurred on sub main.textbox1_keypress.

    error description:
    FormatException
    Continue ?
     
  6. Cableguy

    Cableguy Expert Licensed User

    as I said that was un tested code, an may not suite your needs...
    explore the help file a bit, and you will find lots of examples that may sed some light...since you are not yet a registered b4p user, you cannot download the ControlsEX Dll, that would for sure suite your needs.
     
  7. o2flameuser

    o2flameuser Member

    i explored the manual but cant find
    any suggestions are wellcome
     
  8. Cableguy

    Cableguy Expert Licensed User

    Another aproach would be to add a timer, and set it to 2 or 3 seconds interval, then, of every Focus event of the textboxes, start the timer...On the timer tick event, check the values of the texboxes and do whatever maths you need
     
  9. klaus

    klaus Expert Licensed User

    If you enter only ONE digit into TextBox2, this code works:
    Code:
    [SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]TextBox2_KeyPress(key)[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]TextBox3.Text=TextBox1.Text+key[/FONT][/SIZE]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT]
    If you want to enter a number with more than one digit you need to use the Door library to use the TextChanged event like:
    Code:
    [SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Globals[/SIZE][/FONT]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]'Declare the global variables here.[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] a=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New][COLOR=#0000ff]
    [SIZE=
    2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]App_Start[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New] objTextBox2.New1([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]False[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New] objTextBox2.FromControl([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"TextBox2"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New] evtTextBox2.New1(objTextBox2.Value, [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"TextChanged"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New] Form1.Show[/FONT][/SIZE]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New][COLOR=#0000ff]
    [SIZE=
    2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]evtTextBox2_NewEvent[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New] a = TextBox2.Text[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New] TextBox3.Text=TextBox1.Text+a[/FONT][/SIZE]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    I don't understand exactly what you want to do with your file.
    Why do you want to open it with a Shell command and with what program.
    You can open a file within the program with FileOpen(c1,"logs.txt",cRead)

    Do you want to use a Word file *.doc or just a simple text *.txt file.

    In The code you show there is no FileClose(c1) ?

    Do you have some sample code we could look at ? It's much easyer for us to look at the complete code rather than on some sub parts.

    Best regards.
     
  10. o2flameuser

    o2flameuser Member

    tnx for all your reply
    but i solved it
    gotfocus did the work by this type

    firstly i set to 3 textbox as a variable 0
    then

    Sub TextBox1_gotfocus
    TextBox3.Text=TextBox1.Text+TextBox2.Text
    End Sub

    Sub TextBox2_gotfocus
    TextBox3.Text=TextBox1.Text+TextBox2.Text
    End Sub

    for each textbox 1 gotfocus

    and thats is the what i want

    tested and working

    but could not find a soln for my second problem

    in fact the program does not allow me to open my logs.txt file (that is my database) while running but when i exit my program i can open it with the pocketword (logs.txt) and see my datas

    any suggestion to solve this problem ?
     
  11. o2flameuser

    o2flameuser Member

    yes i want to my file show on pocket word
    i include fileclose(c1) but it doesnot open when the program run
    any help ?
     
  12. klaus

    klaus Expert Licensed User

    You could also use the LoasFocus event.

    I made the proposal with the Door library because you didn't want another mouseclick to transfer the result into TextBox3. But in your example, you need a mouseclick to transfer it, like clicking on a button would do the same, and from a user's point of view probably more obvious, but that is just a personal feeling.

    For you saving problem, I still don't really understand what exactly you want to do !
    If you want to save and read the same file at the same time it's not possible. But instead of saving your intermediate data and or results in a file you could save them in array, in the program, and save the array when you quit the program. But you have all your data available in the array while the program is running. When starting the program you could even read the file back with previous data into the array and add the new ones and save again at the end.
    But for me it's still not clear what you want to save and when and what you want to have back, when and for what. So it's difficult to give concrete advices.

    Best regards.
     
  13. o2flameuser

    o2flameuser Member

    ok mate
    here is my code

    Sub Globals
    H=0
    P1=0
    P2=0
    P3=0
    P4=0
    P5=0
    P6=0
    TP1=0
    TP2=0
    TP3=0
    TP4=0
    TP5=0
    TP6=0
    FileOpen (c1,"logs.txt",cWrite)


    Textbox9.Text = Time(Now)

    End Sub

    Sub App_Start
    Form1.Show

    End Sub




    Sub Button1_Click
    Textbox10.Text = 0
    P1 = Textbox11.Text
    P2 = Textbox12.Text
    P3 = Textbox13.Text
    P4 = Textbox14.Text
    P5 = Textbox15.Text
    P6 = Textbox16.Text

    If (P1+P2+P3+P4+P5+P6<>0) Then Goto HERE:


    TOPP1 = P1+TP1
    TOPP2 = P2+TP2
    TOPP3 = P3+TP3
    TOPP4 = P4+TP4
    TOPP5 = P5+TP5
    TOPP6 = P6+TP6

    Textbox21.Text = TOPP1
    Textbox22.Text = TOPP2
    Textbox23.Text = TOPP3
    Textbox24.Text = TOPP4
    Textbox25.Text = TOPP5
    Textbox26.Text = TOPP6

    TP1 = P1+TP1
    TP2 = P2+TP2
    TP3 = P3+TP3
    TP4 = P4+TP4
    TP5 = P5+TP5
    TP6 = P6+TP6

    Textbox7.Text = Date(Now)
    Textbox8.Text = Time(Now)
    H=H+1
    Textbox30.Text = H

    Textbox11.Text = 0
    Textbox12.Text = 0
    Textbox13.Text = 0
    Textbox14.Text = 0
    Textbox15.Text = 0
    Textbox16.Text = 0
    FileWrite (c1,textbox1.Text&cTab&textbox2.Text&cTab&textbox3.Text&cTab&textbox4.Text&cTab&textbox5.Text&cTab&textbox6.Text)

    FileWrite (c1,textbox21.Text&cTab&textbox22.Text&cTab&textbox23.Text&cTab&textbox24.Text&cTab&textbox25.Text&cTab&textbox26.Text)

    Goto there:
    HERE:
    Msgbox ("ERRORS FOUND!!! POT IS NOT CORRECT PLEASE CORRECT IT")

    there:
    End Sub


    Sub Form1_Show

    End Sub

    Sub Form1_Close

    End Sub

    Sub Button2_Click
    FileClose (c1)
    FileOpen (c1,"logs.txt",cRead)

    End Sub

    Sub TextBox11_GotFocus
    Textbox10.Text = Textbox11.Text+Textbox12.Text+Textbox13.Text+Textbox14.Text+Textbox15.Text+Textbox16.Text
    End Sub

    Sub TextBox12_GotFocus
    Textbox10.Text = Textbox11.Text+Textbox12.Text+Textbox13.Text+Textbox14.Text+Textbox15.Text+Textbox16.Text
    End Sub

    Sub TextBox13_GotFocus
    Textbox10.Text = Textbox11.Text+Textbox12.Text+Textbox13.Text+Textbox14.Text+Textbox15.Text+Textbox16.Text
    End Sub

    Sub TextBox14_GotFocus
    Textbox10.Text = Textbox11.Text+Textbox12.Text+Textbox13.Text+Textbox14.Text+Textbox15.Text+Textbox16.Text
    End Sub

    Sub TextBox15_GotFocus
    Textbox10.Text = Textbox11.Text+Textbox12.Text+Textbox13.Text+Textbox14.Text+Textbox15.Text+Textbox16.Text
    End Sub

    Sub TextBox16_GotFocus
    Textbox10.Text = Textbox11.Text+Textbox12.Text+Textbox13.Text+Textbox14.Text+Textbox15.Text+Textbox16.Text
    End Sub

    Sub Button3_Click
    FileOpen (c1,"logs.txt",cWrite)
    Form1.show
    End Sub
     
  14. o2flameuser

    o2flameuser Member

    and here is my complete prog
     
  15. Cableguy

    Cableguy Expert Licensed User

    You shouldn't use FileOpen in globals, it is not an elegant way of doing things...
    The globals shoul be used to just that, global variables...(This is my Opinion...)
    You should use it before any fileWrite statement...like this:
    This way the file is released and can be opened from outside the app
     
  16. klaus

    klaus Expert Licensed User

    Here you have a somewhat modified program with storing the data in array variables.
    I have changed the control names to use selfexplaining names, for example 'txtDate' says more than 'TextBox30'.
    I have added some more advanced keywords to show you what can be done with Basic4PPC.
    I have added a save button to save the whole dada at once, with a comma as a separator character and with a csv extension. This file could be directly improted into a Table control.
    You could show your data in a Table control.

    Best regards.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice