Results 1 to 9 of 9

Thread: Passing Data Over Form Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    14

    Passing Data Over Form Problem

    i have one form that read user input it will assign to a public variable, here is the code
    Code:
    ElseIf IsNumeric(txt1.Text) = True And IsNumeric(txt2.Text) = True And IsNumeric(txt3.Text) = True Then
                            Main.text1 = CInt(txt1.Text)
                            Main.text1 = CInt(txt2.Text)
                            Main.text1 = CInt(txt3.Text)
                            Main.Access = 1
                            Main.Custom = 1
                            Me.Close()
                            Main.Show()
                        End If
    i have set the variable as this :
    Code:
        Public text1 As Integer
        Public text2 As Integer
        Public text3 As Integer
    the problem is when iam call at a function
    Code:
    test = (ascode * Main.text1)
    test = (ascode / Main.text2)
    test = (ascode - Main.text3)
    the integer which set in "text1,text2,text3" changed into hex? while i need it in integer ;(

    here is the value when called in that function
    Code:
    Main.text1 = &H28
    Main.text2 = &H5
    Main.text3 = &H3C
    i even have tried convert it back to integer
    Code:
    test = (ascode * cint(Main.text1))
    test = (ascode / cint(Main.text2))
    test = (ascode - cint(Main.text3))
    same always got hex? code

    also trying this
    Code:
    ElseIf IsNumeric(txt1.Text) = True And IsNumeric(txt2.Text) = True And IsNumeric(txt3.Text) = True Then
                            Main.text1 = CInt(txt1.Text.ToString)
                            Main.text1 = CInt(txt2.Text.ToString)
                            Main.text1 = CInt(txt3.Text.ToString)
                            Main.Access = 1
                            Main.Custom = 1
                            Me.Close()
                            Main.Show()
    End If

    how to fix this?? any help appreciated , thx for reading this question

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    14

    Re: Passing Data Over Form Problem

    anyone?

  3. #3
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: Passing Data Over Form Problem

    First off when defining integer variables, you shoud not use the word text, it is not good practice, try naming them something like int1,int2,int3 instead
    VB Code:
    1. If Integer.TryParse(txt1.Text,Main.int1) And Integer.TryParse(txt2.Text,Main.int2) And Integer.TryParse(txt3.Text,Main.int3) Then
    2.     Main.Access = 1
    3.     Main.Custom = 1
    4.     Me.Close()
    5.     Main.Show()
    6. End If
    When using this method, the three variables will be set to the value if it is an integer

    As for the rest, I do not see why it is coming back in hex value. What are test and ascode defined as?
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    14

    Re: Passing Data Over Form Problem

    Quote Originally Posted by bmahler
    First off when defining integer variables, you shoud not use the word text, it is not good practice, try naming them something like int1,int2,int3 instead
    VB Code:
    1. If Integer.TryParse(txt1.Text,Main.int1) And Integer.TryParse(txt2.Text,Main.int2) And Integer.TryParse(txt3.Text,Main.int3) Then
    2.     Main.Access = 1
    3.     Main.Custom = 1
    4.     Me.Close()
    5.     Main.Show()
    6. End If
    When using this method, the three variables will be set to the value if it is an integer

    As for the rest, I do not see why it is coming back in hex value. What are test and ascode defined as?
    same i awlays got hex code
    ascode = asc(word1)
    change from one word into ascii code

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    14

    Re: Passing Data Over Form Problem

    Code:
    If Integer.TryParse(txt1.Text,Main.int1) And Integer.TryParse(txt2.Text,Main.int2) And Integer.TryParse(txt3.Text,Main.int3) Then
    why u give another solution for "isNumeric" ? the one i really need is how to pass integer from one form to another form,the source of the value is from 3 textbox and when a button clicked it will be assigned to a public variable

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    14

    Re: Passing Data Over Form Problem

    Seem to be Passing Variable between several function on one Module in vb has a problem,u can try using integer,it will automaticly converted to hex value,the problem now is how to convert from hex back to integer inside one module??? what is the easiest way?

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    14

    Re: Passing Data Over Form Problem

    Saeem My English is not good enough to explain my problem lol,

    here is my problem condition
    first i declared a public variable on "Main.Form"

    VB Code:
    1. Public text1 As Integer
    2.     Public text2 As Integer
    3.     Public text3 As Integer

    On the second form i have 3 textbox and 1 button,when the button clicked it will first verified the data whether numeric or not and if it's ok continue to set the value from the three text box into 3 public variable on Main.Form
    VB Code:
    1. ElseIf IsNumeric(txt1.Text) = True And IsNumeric(txt2.Text) = True And IsNumeric(txt3.Text) = True Then
    2.                         Main.text1 = CInt(txt1.Text)
    3.                         Main.text1 = CInt(txt2.Text)
    4.                         Main.text1 = CInt(txt3.Text)
    5.                     End If

    and also i have a function in module which something like this :
    VB Code:
    1. test = (ascode * Main.text1)
    2. test = (ascode / Main.text2)
    3. test = (ascode - Main.text3)


    somehow when i trigger the function the Main.Text1,Main.Text2,Main.Text3 value inside of the module always changed into hex value! ,
    Sample :
    VB Code:
    1. Main.text1 = &H28
    2. Main.text2 = &H5
    3. Main.text3 = &H3C

    how to always keep real integer inside the module?? i didn't experience this on normal Form , already tried with Cint(Main.text1) , all same always hex value
    Last edited by Sabour; Sep 21st, 2006 at 09:25 PM.

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Passing Data Over Form Problem

    Could you tell us what the real integers are?

    This is a really weird sounding problem, and I have a feeling that the solution is not in code, but in some IDE setting. The reason I think this is because these two statements are identical:

    Dim int1 = 5
    Dim int1 = &H5

    As far as the program goes, it makes not the slightest bit of difference. From all you have said, this looks like some output setting rather than a programming issue.
    My usual boring signature: Nothing

  9. #9

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    14

    Re: Passing Data Over Form Problem

    Real Integer?
    VB Code:
    1. Main.text1 = &H28
    2. Main.text2 = &H5
    3. Main.text3 = &H3C
    came from this value
    VB Code:
    1. Main.text1 = 40
    2. Main.text2 = 5
    3. Main.text3 = 60

    then how it can from integer changed into hex code automaticly? o_0 big diff for me because the result for calculating using hex is corrupt integer result for me :
    VB Code:
    1. test = (ascode * Main.text1)
    2. test = (ascode / Main.text2)
    3. test = (ascode - Main.text3)

    i don't know why but example ascode contain value "612" even calculate with Main.text1, divided by Main.text2 , and reduce with Main.text3, the ascode value stay same ,also there is interesting things for me,why word "*","/","-" on arithmatic operation always automaticly set to double by vb? this could be the problem???

    if u have some freetime would u check my full project? i cann't post it on public since it's my unix first semester final project , deadline is next couple days,omg hope i can finish this :/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width