473,471 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help regarding reading numbers from text box into a variable!!!

24 New Member
I was having problem in reading a number from the text box, as it contains data in text form. Can anyone tell how to read data into an integer variable from a text box.
Jun 5 '07 #1
3 2947
PdBeer
5 New Member
If you are using VB6 you can use the Int() fuction to convert the string into an integer.
For example:

Dim num as integer
num = int(text1.text)
Jun 5 '07 #2
Killer42
8,435 Recognized Expert Expert
You can also use the Val() function. Hm... actually, if you feel like it, you can just assign it straight to the variable without using any function - VB is actually pretty smart like that).

It depends a bit on what you want. The Int() function will truncate the number, otherwise it will be rounded. For example, converting "58.6" to an Integer variable will round up to 59, unless you use Int() function which will truncate it and return 58.

Also, a straight assignment or the Int() function will produce a Type Mismatch error if the value isn't numeric (for example, "Text1") while Val() function will return 0.
Jun 5 '07 #3
eklavyavats
24 New Member
You can also use the Val() function. Hm... actually, if you feel like it, you can just assign it straight to the variable without using any function - VB is actually pretty smart like that).

It depends a bit on what you want. The Int() function will truncate the number, otherwise it will be rounded. For example, converting "58.6" to an Integer variable will round up to 59, unless you use Int() function which will truncate it and return 58.

Also, a straight assignment or the Int() function will produce a Type Mismatch error if the value isn't numeric (for example, "Text1") while Val() function will return 0.
thanks for your help dude!!!!!!!!
Jun 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Yeow | last post by:
hello, i was trying to use the fread function on SunOS and ran into some trouble. i made a simple test as follows: i'm trying to read in a binary file (generated from a fortran code) that...
1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
1
by: mart2006 | last post by:
Hi, I'm currently reading a text file via PHP which, in itself, is very easy. However I want to specifically get one word from the text file and assign it as a variable and I'm struggling like...
1
by: flavourofbru | last post by:
Hi All, I have a small question regarding accessing the text files in C++. Here is what I am writing in C++. Tha algorithm is as follows: for j = 2:length(image) { Red =...
2
by: holdit | last post by:
Ok guys, I ahve this homewrok question I have been working on but I can't seem to find the solution for it. I have to upload a text file of this kind: 4 6 000000 011000 001100 001110 into...
1
by: kazper | last post by:
Good day to all, I would like to ask for your expertise regarding putting numbers for each item for each group on my report (Visual Basic 6) Example of report HR Department No. ...
2
by: mahesh123 | last post by:
Hi Folks, I am generating the text reports from the visual basic 6.0. while printing the text report the Char(12) ie page break character is not recognising. Is there any alternate Solution for...
4
by: dacuteangel04 | last post by:
ok what my program is suppost to do is open a file - Grades.txt and read each line the breaking the lines down w/ tokens so i may later average some numbers an example some of the lines from the...
8
by: slizorn | last post by:
Hi guys, I have this coding that I wanted to try out. Basically this is meant to be done in Java as practice for the Topic trees in data structures and algorithms. I have recently learned C++ on...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.