|
-
Sep 21st, 2006, 12:53 PM
#1
Thread Starter
New Member
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
-
Sep 21st, 2006, 03:15 PM
#2
Thread Starter
New Member
Re: Passing Data Over Form Problem
-
Sep 21st, 2006, 03:31 PM
#3
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:
If Integer.TryParse(txt1.Text,Main.int1) And Integer.TryParse(txt2.Text,Main.int2) And Integer.TryParse(txt3.Text,Main.int3) Then
Main.Access = 1
Main.Custom = 1
Me.Close()
Main.Show()
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?
-
Sep 21st, 2006, 03:59 PM
#4
Thread Starter
New Member
Re: Passing Data Over Form Problem
 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:
If Integer.TryParse(txt1.Text,Main.int1) And Integer.TryParse(txt2.Text,Main.int2) And Integer.TryParse(txt3.Text,Main.int3) Then
Main.Access = 1
Main.Custom = 1
Me.Close()
Main.Show()
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
-
Sep 21st, 2006, 04:23 PM
#5
Thread Starter
New Member
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
-
Sep 21st, 2006, 06:19 PM
#6
Thread Starter
New Member
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?
-
Sep 21st, 2006, 09:16 PM
#7
Thread Starter
New Member
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:
Public text1 As Integer
Public text2 As Integer
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:
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)
End If
and also i have a function in module which something like this :
VB Code:
test = (ascode * Main.text1)
test = (ascode / Main.text2)
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:
Main.text1 = &H28
Main.text2 = &H5
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.
-
Sep 21st, 2006, 09:28 PM
#8
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
 
-
Sep 21st, 2006, 10:46 PM
#9
Thread Starter
New Member
Re: Passing Data Over Form Problem
Real Integer?
VB Code:
Main.text1 = &H28
Main.text2 = &H5
Main.text3 = &H3C
came from this value
VB Code:
Main.text1 = 40
Main.text2 = 5
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:
test = (ascode * Main.text1)
test = (ascode / Main.text2)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|