Vb6 Using A Number

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > VB Programming

Vb6 Using A Number

kvarnerexpress
Little background on project.
I'm pretty new at VB6 and database stuff.
I'm using a MS Access database
Use DAO 3.6 as reference

Ok here is the problem... when I first made my table I set almost every column as a Text type other than the few dates I had.

Now that I have gotten more into my program I have added a ORDER BY in my SQL statements during a query.

Because I have everything set to text it doesn't sort Numbers right. For example

10
110
20
21
25
32
345
37

That is what it would do.

But when I changed my column to Number format in the database. I get a mismatch critiria error with my queries.

Searchmore gets it's value from text1.text it could be a string, number, or date.
Searchfield gets it's value from a combobox

I tried this below to change it from a string to numeric. BUt still got the same error and it points me to my query statement.

Code:
If isnumeric(text1.text) = true then
searchmore = val(text1.text)
else
searchmore = trim(text1.text)
end if

I am guessing I have to make a special SQL statement if the variable searchmore is numeric? Or if the column that I am query is not text?


Code:
Set rs = db.OpenRecordset("Select * from Production where " & Searchfield & " < '" & Searchmore & "' Order by " & Sortby & " " & Sortorder)

Works with a LIKE but not if I query with < , > , <>.


Code:
Set rs = db.OpenRecordset("Select * from Production where " & Searchfield & " LIKE '" & Searchmore & "' Order by " & Sortby & " " & Sortorder)

So what do I need to do to be able to search that Column that is now in Number format and not text?

Thanks Again

 

 

 


Reply

Galahad
All you have to do, is leave out single quotation marks (')

That is, following code:
CODE
Set rs = db.OpenRecordset("Select * from Production where " & Searchfield & " < '" & Searchmore & "' Order by " & Sortby & " " & Sortorder)
will not work, because you put Searchmore variable inside single quotes, and that tells database engine to evaluate it as a string (or text).
What you need to do, is simply leave out those single quotes, like this:
CODE

Set rs = db.OpenRecordset("Select * from Production where " & Searchfield & " < " & Searchmore & " Order by " & Sortby & " " & Sortorder)
and this code should work fine now.

When you want something evaluated as string (or text), you put it inside single or double quotes. And if you want it evaluated as a number, just leave out the quotes.

Here are two examples, of SQL statements, one for text, and one for number search:
CODE

SQL = "SELECT * FROM TableName WHERE FieldNumber > 1 ORDER BY FieldNumber ASC;"

SQL = "SELECT * FROM TableName WHERE FieldText LIKE '1' ORDER BY FieldText DESC;"
You can use all comparison operators (<, >, <>, =, >=, =<, LIKE, etc.) with both text and numbers. LIKE is however most usefull when comparing strings...

Hope this cleared things up smile.gif

 

 

 


Reply

dul
Sorting is still difficult. But try to ust you texts to numeric using function StringToIng or something. Then use the sorting function. It could help you.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. number format in vb - 0.43 hr back. (1)
  2. 3 digit guessing game in vb - 11.45 hr back. (1)
  3. vb6 using numbers in code data type - 38.30 hr back. (1)
  4. order by vb6 - 46.51 hr back. (1)
  5. vb6 string to numeric - 62.57 hr back. (1)
  6. find maximum number in an array using vb6 - 67.62 hr back. (1)
  7. vb6 check if number is odd - 73.66 hr back. (1)
  8. vb6 is number - 88.32 hr back. (1)
  9. vb numeric format - 88.50 hr back. (1)
  10. text or number vb - 103.43 hr back. (1)
  11. vb how to pick a numeric in a string - 108.78 hr back. (1)
  12. vb6 compare numbers - 109.95 hr back. (1)
  13. vb numberformat example - 126.96 hr back. (1)
  14. number in vb6 - 131.75 hr back. (1)
Similar Topics

Keywords : vb6, number

  1. Get Pan Number Online
    (0)
  2. Ti Basic: Pick A Number
    (1)
    Description Learn how to create a neat-o Game in TI Basic. Its basic premise is that someone
    picks a number, then they pass the calculator to their friend, and they try to guess the number.
    Once the successfully guess the number a message appears and says that they have won. I have also
    included a line that keeps users from choosing numbers greater than one-hundred. Please Enjoy.
    Try I Out Alright.... just input what you see below and I'll explain it a little below.
    CODE :ClrHome :Lbl 2 :Prompt A :A->X :If X>100 :Goto 2 &#....
  3. Make A Big Number!
    What is the largest number you can make with... (8)
    What is the largest number you can make with 3 one-digit numbers? You've no doubt heard this
    one before. The answer you all know and love is 9 ^ 9 ^ 9, or some 369-million digit number that
    appears in Pi somewhere but no one cares to memorize. Here are a few rules to that game: 1. The
    number must be less than infinity. 2. You cannot use unary operators. (Unary operators are operators
    that only require one argument to work, such as factorials. 1 + 2 = 3 is a binary operator, since it
    has two arguments, 1 and 2.) 3. If you use an iterated binary operator (one that i....
  4. Zk
    the number 1 Ajax Framework (2)
    ZK is an open-source Ajax Web framework that enables rich user interface for Web applications with
    little programming. Its an event-driven, component-based framework to enable rich user interfaces
    for Web applications. ZK includes an AJAX-based event-driven engine, a rich set of XUL and XHTML
    components and a markup language called ZUML (ZK User Interface Markup Language). With ZK, you
    represent your application in feature-rich XUL and XHTML components and manipulate them upon events
    triggered by user's activity, similar to what is done in desktop applications. Un....
  5. Count Number Of Div's By A Class Name
    (3)
    I have a situation where I need to be able to count the number of div elements in a page and then
    use that number for a loop. I've already tried this but it returns all child div elements.
    ocument.getElementById("char_list").getElementsByTagName("div").length; I need only the child nodes
    directly below the parent div 'char_list'. THe structure is like this The
    problem here is I also have nested div's inside the 'char_node' divs so the first code
    returns them all. I'm trying to just gather the char_node class divs and use i....
  6. Data Structure -- Arrays -- Odd Number Of Elements
    (0)
    Given an array of elements with many numbers occurring even number of times and two numbers
    occurring odd number of times. Find out the two numbers that occur odd number of times. example:
    Elements in array -- 14433446 The expected result is 1 and 6 One solution 1. Find max of the
    array 2. Hash Function : element/max value 3. Repeat to all elements... 4. Find frequency... yo will
    get the 2 elements with odd frequency. but this is not the optimal.... Do find more solutions to
    this and post it. Look for time and space complexity. Another Solution one more s....
  7. Which Data Type To Use In Mysql Table
    Using a 5 character number (4)
    If I wanted to use an ID field which automatically increments when data are addad, but displays the
    ID as a 5 figure number, which data type would I have to use? I would want a type that assigns a
    number to a record in the format "00001", "00002", etc. However, when I use "int" as datatype, it
    only displays th field contents as "1", "2" etc. So, which data type could do the job for me? i do
    not need a decimal point or anything, just an id that displays in 5 figures, including the leading
    zeros. Thanks in advance.....
  8. Ireland O2 Number
    looking for people (0)
    Sorry for this topic but I need find someone who have Ireland o2 mobile number and is using it. .
    Is someone here? (Please send this topic to good category because I don't know where I have to
    pick it.. Thanks....
  9. India Is Now Nokia's Number-two Market
    (0)
    Have you ever thought how nokia;s profit is jumping its because of India, even though most of the
    phones of nokia are manufactured in China.,its world second largest market is India., beating USA.
    READ THIS NEWS . QUOTE The world's top mobile-phone maker shipped 60 million handsets from
    its factory near the southern Indian city of Chennai in the 18 months up to August. Chief executive
    Olli-Pekka Kallasvuo expects demand to remain strong as India's user base surges. "India has
    quickly become one of the largest markets," he told reporters in New Delhi, addin....
  10. Can Database Column Names Start With A Number?
    Can database column names start with a number? (1)
    Can database column names start with a number or must they start with a letter like php vars? Like
    my_table.1fieldname ? Does this vary from db system to db system? Is it considered good/bad form? ....
  11. Displaying Your Phone Number On A Wap Site
    (3)
    I have a wap site elitezone.co.za and what i want to add is a code to the index page that displays
    your operator and phone number. Does any one know the coding for this function if so please show me
    here. Help will appriacated. Topic title modified. ....
  12. Universe? Single Or Infinite
    Can we have 'n' number of universes (12)
    hi friends, i feel that the topic i am discussing is quiet interesting because it leads to many
    possibilities by having just one simple fact in mind.... and that fact is that everything is
    relative... nothing is too big or too small or too fast or too slow.... everything can be discounted
    by something else... so our universe though very big could be like a ball in some other universe...
    also before starting i would like to add that the theory that i am trying to tell is just my
    imagination and it is as such without any proof or any scientific material about it is not t....
  13. How To Make A Random 7 Number Code?
    (2)
    I am making a script in php, and for it I need to know how to make a random 7 digit code. I think it
    has something to do with md5, but i am not sure. Thanks! EDIT- Can someone please change the
    title to "How to make a random 7 digit code in php?" Thanks!....
  14. Limiting Max Number Of Credit Posts Suggestion?
    (19)
    How about that Trap17 limits maximum number of posts that you can get credits for in one day? My
    suggestion would be limiting posts that count for credits at 3 a day /rolleyes.gif"
    style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> . I really
    don't know how to explain this idea, it's just something that came to my mind.. What do you
    guys think?....
  15. Mathematical Proof
    ...that there is no largest prime number (11)
    In math, a proof is basically just that, proof that something is true. Proofs must be rigid, they
    cannot be based on assumptions. For example, just because we keep finding bigger and bigger prime
    numbers, it does not mean there are infinitely many. However, there is a proof for that. First,
    assume that there is, in fact, a largest prime number. Call it "P." That is, there is no prime
    that is greater than P. (It's OK to assume things like this in a proof sometimes; for example,
    it's OK here because we intend to prove that our assumption is wrong, that it le....
  16. The Social Security Number Is The Mark Of The Beast?
    (5)
    What is the purpose of the social security number? Well here are some verses from Revelations
    Chapter 13 QUOTE 13:15 It was given to him to give breath to it, to the image of the beast,
    that the image of the beast should both speak, and cause as many as wouldn't worship the image
    of the beast to be killed. 13:16 He causes all, the small and the great, the rich and the poor,
    and the free and the slave, to be given marks on their right hands, or on their foreheads; 13:17
    and that no one would be able to buy or to sell, unless he has that mark, the name of th....
  17. Problem Setting Up Addon Domain As Allowed Number Is 0 [resolved]
    cannot add an addon domain as I have 0 allowed! (2)
    Right... a couple of days ago I registered another domain for use as well as my main one
    www.projectjim.co.uk Today, I realised that I was able to use both with my trap account as putting
    my new domain as an addon /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
    alt="biggrin.gif" /> Trouble is, when I come to make it it won't let me, saying I'm not
    allowed to add any more than (0) addon domains! My cpanel shows 0/0 allowed addon domains (not
    unlimited or 9) On searching I'm pretty sure I have exactly the same problem as the dude in thi....
  18. Find Prime Number
    find prime number code (4)
    Public Function GetPrimeNo (InNoWanted As Integer) As Long Dim lPrimes() As Long Dim lTrial As
    Long Dim lCount As Integer Dim lFound As Integer Dim lCounter As Integer ReDim
    lPrimes(InNoWanted) lTrial = 5 lCount = 3 lFound = 0 'Define the first three prime number
    ' > lPrimes(0) = 2 lPrimes(1) = 3 lPrimes(2) = 5 Do lTrial = lTrial + 2 lFound = 0 For
    lCounter = 0 To lCount - 1 lFound = (lTrial Mod lPrimes(lCounter)) = 0 If lFound Then Exit For
    End If lCounter = lCounter + 1 Next lCounter If lFound = 0 Then lPrimes(lCount) = lTrial lCo....
  19. The Definition Of Google Number [aka Googol]
    No... it's not that search engine! It has a definition. (18)
    Maybe some of you know this already A google is a fantastic number; it is a number followed by 100
    zeros. So when I say you got a google girlfriends, it means you have 10^100 girlfriends. (Aint
    logic) Now we know why the name Google for the famous search engine.....
  20. Which Sig Looks Better?
    Number 1 or Number 2? (5)
    #2 Does this one look better? #1 Or this? I will add a border to both of them I do not like
    how on one of them the text turned out fuzzy.....
  21. Ken Kaniff's Phone Number
    (0)
    I was on Eminem's website and I found out that Ken Kaniff made a phone line for you to call. I
    tried it. It's really funny. If you don't know who Ken Kaniff is get your Eminem Cd's
    and look for a Ken Kaniff Skit.it says, " If you leave your phone number I might call you back you
    little b****." The number is: 360-566-2495 Have Fun! ....
  22. Google A Number?
    (48)
    when i was in 5th grade, which was 5 years ago, this was right when google first came out i think...
    anyways, i remember my 5th grade teacher telling me that the word google was the biggest number
    possible and that it was bigger than infinity. Back then i believed it but then you really think
    about it, how is a number even possibly bigger than infinity if infinity goes on FOREVER? and is
    googe EVEN a number????? anybody know?....
  23. 1 900 Number Scam
    I've got a 'legal' $80 on my phone bill (9)
    I downloaded something...I haven't figured out yet, that caused me to have an extra 80 dollars
    added to my phone bill this month. What happened was that I didn't read the terms of services
    for this download and then my modem dialed up to a 900 number for the download. We called the phone
    company who told us this was from www.infoservices900.com which does this services for a lot of
    companies. I called the number on the website and they couldn't tell me anything about the
    download except reminding me that it its completely legal and that it was my fault for ....
  24. Need Help With C Program To Test If A Number Is Prime
    Ending unexpectedly somewhere near for-loop (12)
    CODE #include <stdio.h> main() {       printf("Enter a number:
    ");              int n;       scanf("%d", &n);              if(n ==
    2)            printf("%d is prime", n);       else if(n % 2 == 0 || n <
    2)            printf("%d is not prime", n);       else       {            int x;
               for(x = 0; x < (int)sqrt((double)n); x++)
                    if(n % x == 0)                 {                      printf("%....
  25. June 6th 2006 - The Devils Number
    Possibly the end of the world? (113)
    Ok, I don't want to start any religious fights here, that's not what this topic is meant
    for. So PLEASE hold the religious comments. I was at school one day, I turned to a friend and said
    "I bet the world will end on June 6th of this year". Now I think they'd know what I meant(goth
    kids, ya, no I'm not one). But they didn't! So I sat there and explained it, all of a
    sudden "Bing" the light in there brain goes off, they said that's really a possibilty. For
    those of you who don't get it; June 6th, 2006 6-6-06 Or without the 0, 6-6-6, 666 W....
  26. Largest Known Prime Number
    A very long number... (115)
    Well, I couldn't find a topic I was really interested in, so I thought I would post on something
    comletely useless... The world's largest known prime number is actually 7,816,230 digits long,
    so I'm not going to type it all out, but the 'Mersenne number' is 225,964,951– 1. It
    was discovered by the Great Internet Mersenne Prime Search (GIMPS), a distributed network of
    volunteers using their spare computer power to find the largest Mersenne primes. This system
    actually discovered the eight largest prime numbers known. And, if you must, you can actual....
  27. Invision Forums Member Number
    How to reset the member number ? (8)
    Hi, I've just created a new forum.. I've also create many test accounts to make sure my
    groups are working with its permissions. Now these test accounts takes up "member number". When I
    remove these test account, the "member number" don't seem to reset, instead it keeps raising..
    So in the end, there's a huge gap in member number before the next real member. I'm
    wondering anyone knows how to reset this member number thing so the gaps are removed. Board is
    Invision version 1.3....
  28. Will Google All Ways Be Number 1 Search?
    (63)
    i have used google for as long as i can remeber but i have try use msn search but i still find my
    self useing google. i think it will be the best forever /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> do you have google set as homepage? do you use
    google?....
  29. Number Guessing Game
    number guessing game (9)
    do you still have the code for that number guessing game?....
  30. What Is Your Lucky Number?
    (23)
    Hey everyone. I was wondering what your lucky number is? It can be any number, doesn't have to
    be a limited size, just please don't come up with a totally random, disruptive and crazy
    number! Mine is: Check my Userid. 3000. Tis mine. 3000.....

    1. Looking for vb6, number

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for vb6, number

*MORE FROM TRAP17.COM*
Similar
Get Pan Number Online
Ti Basic: Pick A Number
Make A Big Number! - What is the largest number you can make with...
Zk - the number 1 Ajax Framework
Count Number Of Div's By A Class Name
Data Structure -- Arrays -- Odd Number Of Elements
Which Data Type To Use In Mysql Table - Using a 5 character number
Ireland O2 Number - looking for people
India Is Now Nokia's Number-two Market
Can Database Column Names Start With A Number? - Can database column names start with a number?
Displaying Your Phone Number On A Wap Site
Universe? Single Or Infinite - Can we have 'n' number of universes
How To Make A Random 7 Number Code?
Limiting Max Number Of Credit Posts Suggestion?
Mathematical Proof - ...that there is no largest prime number
The Social Security Number Is The Mark Of The Beast?
Problem Setting Up Addon Domain As Allowed Number Is 0 [resolved] - cannot add an addon domain as I have 0 allowed!
Find Prime Number - find prime number code
The Definition Of Google Number [aka Googol] - No... it's not that search engine! It has a definition.
Which Sig Looks Better? - Number 1 or Number 2?
Ken Kaniff's Phone Number
Google A Number?
1 900 Number Scam - I've got a 'legal' $80 on my phone bill
Need Help With C Program To Test If A Number Is Prime - Ending unexpectedly somewhere near for-loop
June 6th 2006 - The Devils Number - Possibly the end of the world?
Largest Known Prime Number - A very long number...
Invision Forums Member Number - How to reset the member number ?
Will Google All Ways Be Number 1 Search?
Number Guessing Game - number guessing game
What Is Your Lucky Number?
advertisement



Vb6 Using A Number



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE