Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Fraction Part Of A Number?


Hi all!

I have a really simple question:

How do I get the fraction part of a number.
Ex: .75 from 4.75


(I could only find lots of posts on the Int(number) function which returns the integer part)

Thanks!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Get The Fraction Of A Number
I've got a pretty dumb question. First of all, let me explain that I've worked with MANY Basic languages, so sometimes I slightly confuse myself with the other variants.

But here's the question:
How do you get the fraction of a number? So when I have got the number '7.12' I want to have just the '0.12' to do the rest with. With some of the other Basic languages it was the command 'Frac()' I believe. But it seems that Visual Basic has no such command.

So anyone who does know the command for this action?
Or maybe (as an alternative) a function for doing this?

Many thanks in advance,


Chavez

Decimal Number Become Fraction Number
Could you help me this problem:
How can I change a decimal number to fraction number?
For example:
0,3333 become 1/3
thank you!

Cell Value In Fraction Number
I have a little problem my fraction numbers are converted in decimal number and i need to keep the number in fraction

cell a1 number is 6 1/2


i have a macro

h=cells(in1,1).value

cells(4,1).value=h

this convert 6 1/2 to 6,5 but i need to keep this number at 6 1/2

Thank you

Creating Fraction/number Constants
Ok, I have another lame question.

I need to create a program here for work that uses fractions. The fractions will represent weight in foot pounds for bar stock. They are constant values.

So to cut to the chase, this is what I need

Public Const 3/16 as Single = 0.120
Public Const 1/4 as Single = 0.213
Public Const 5/16 as Single = 0.332

now obviously I cant use 5/16 as a variable name, so any tips on an alternate naming convention for this? Is there one that is commonly used?

Thanks for looking


Max.

Finding Decimal Of A Whole Number + Fraction Question
if I wanted to find the decimal of a whole number + fraction. for example 1 1/2 (which would be 1.5), would i use a data type of decimal?

Function, Takes Fraction, Returns Fraction In Reduced Form
Hi guys,
I need to create a function that takes Numerator and Denominator respectively like this MyFraction(3, 6), and returns it in reduced form like (1,2)
All I can think of is a infinite loop.>_<
Any direction pionting would be appreciated.^_^

Expressing A Repeating Decimal Number As A Fraction (Unresolved)
Hi there! I posted this in the Math forum but the traffic being so slow there, I thought I'd post it here too.
Recently, someone asked me to come up with a small app that could simply add 2 fractions (with sums being inferior to 1) and display the result as a fraction as well (not in decimal form).
I thought this was going to be easy at first but I got stumped early on with this.
Actually adding the 2 fractions is nothing but getting the result as a fraction is another matter.
For the most part I got it working using the function below which works well on decimal numbers without long repeating patterns, but on fractions such as 1/7 with a decimal equivalent of 0.142857142857142857142857142857143 the function gracefully fails.
I guess what I need is a formula (preferably in VB) that would reduce those long repeating patterns within the numerator and getting the denominator value right before calling the function.

Again, as this sample all I'm trying to achieve is to come up with and display the 17/21 in my MessageBox:
1 2 17
-+-=-
7 3 21
Math was never my forte in school and I wish now that I would have paid a little more attention during my math class
Anyway thanks in advance!

Here's what I got so far:

VB Code:
Private Sub Command1_Click()Dim lngNumerator As Long, lngDenominator As Long, lngCommonFactor As Long lngNumerator = 5 lngDenominator = 10 If GetCommonFactor(lngNumerator, lngDenominator, lngCommonFactor) Then     MsgBox lngNumerator & " / " & lngDenominatorEnd If End Sub Public Function GetCommonFactor(Numerator As Long, Denominator As Long, CommonFactor As Long) As Boolean    Dim lngIdx As Long        CommonFactor = 1        For lngIdx = Numerator To 2 Step -1        If Numerator Mod lngIdx = 0 Then            If Denominator Mod lngIdx = 0 Then                CommonFactor = lngIdx                Numerator = Numerator / CommonFactor                Denominator = Denominator / CommonFactor                GetCommonFactor = True                Exit For            End If        End If    Next End Function

Integer Part Of A Number
this is a rather simple probleme, yet i havent found a simple solution.

I want to retain the whole value of a number without rounding.
Example:
if number = 2,75 then i want 2 to be returned

french word for this would be to "tronquer", basicly, i want to cut off the decimal part. I tryed several approch to this but VB really likes to round up numbers.

any suggestion?
thx

Decimal Part Of A Number
Is there a vb command like INT() to return the decimal part of a number?

I know I could use n - int(n) but is there a built in command?

Decimal Part Of A Number
How can I get the decimal part of a number?
eg: 3.87 I need to get 87
int(3.87) returns 3
Like that is there a way to get the decimal part?
thx

Number Part In Decimal
Hi!

I want to separate the "Number part" in a Decimal Number.

In 9.5365 I require the value 9 alone.


in the program
---------------------------------------------------------------------------
Dim x As Integer
Dim y As Integer

Dim result As Integer

x = 19
y = 2

result = x / y

Text1.Text = result 'result rounds to 10 instead of 9

End Sub
---------------------------------------------------------------------------

Is it possible in a decimal number (Single data type) to take out
the number part (omitting the decimal part).

Do I've to do casting? If so the format please.

This I require it in my project. Kindly inform.

With regards,
James Mohan

Isolate Part Of A Number
hi all

If I have a set of numbers for example 2504, 8903, 5602 is there a way to get the last two digits so I get 04,03,02?

thanks

Integer And Decimal Part Of A Number
Hello,

I'm designing a fonction to extract hour, second, minute parts from a decimal second number. I'm using Currency data type with four decimal digits allowed. But to convert hour decimal until second decimal, I need a more accurate data type that' s why I'm using inside the sub a double number (named V001).

I precise TimeInSeconds parameter in my GetTimeElements sub and then this sub gets back all others parameters.
To achieve my time sub, I need to deal with Integer and decimal part of a number. I've found a solution, let's see please:


Quote:




Private Function PartDec(ByVal Number As Double) As Double
PartDec = (Number - Int(Number))
End Function

Public Sub GetTimeElements(ByVal TimeInSeconds As Currency, _
Optional Hours As Currency, _
Optional Minutes As Currency, _
Optional Seconds As Currency, _
Optional MilliSeconds As Currency, _
Optional DecimalHours As Currency, _
Optional DecimalMinutes As Currency, _
Optional DecimalSeconds As Currency, _
Optional DecimalMilliSeconds As Currency)


Dim V001 As Double 'My double number!

TimeInSeconds = Abs(TimeInSeconds)

V001 = CDbl(TimeInSeconds) / 60 / 60
DecimalHours = CCur(V001)
DecimalMinutes = CCur(TimeInSeconds / 60)
DecimalSeconds = CCur(TimeInSeconds)
DecimalMilliSeconds = CCur(TimeInSeconds * 1000)

Hours = CCur(Int(V001))

V001 = PartDec(V001) * 60

Minutes = CCur(Int(V001))

V001 = PartDec(V001) * 60

Seconds = CCur(Int(V001)) 'My line

MilliSeconds = CCur(PartDec(V001))

If MilliSeconds > 0 Then MilliSeconds = 10 ^ (Len(CStr(MilliSeconds)) - 2) * MilliSeconds

End Sub






I've test it with TimeInSeconds with 100 seconds : my calculate machine tells me 1 minute and 40 seconds, my sub GetTimeElement 1 minute and 39 seconds...

I've surrounded my problem for this special case here:

Quote:




Seconds = CCur(Int(V001))





V001 is a double and according to vb spy, this variable is egal to 40, when I use int to get integer part, well, this number becomes 39!


Well, I ask anyone who can help me to solve these vb() problem for me... : How can I extract accurately an integer part and a decimal part from a number, a double one?

Thanks in advance.

Getting A Drive&#039;s Part Number (not Serial)
I've used the GetVolumeInformation to return the serial number of a CD that is in the CD Drive on my computer - so I know it's not right for what i want to do now!

I want to get the serial (or is it part/product) number for my CD Drive (and any other drive for that matter) - e.g. DVD2240E for my Creative Labs DVD Drive.

I think I could get it through BIOS but this involves getting the WMI download from Microsoft and if there's an easier solution I'd appreciate it.

Thanks in advance

Matt

Function To Get Integer Part Of A Float Number
is there any internal function to get the integer part of a float number?

the operator "" , or the cint() function returns round up numbers.

thanks

A Way To Add A Number With Commas In A Data Part Of A List?
I'm wondering, is there a way I can add ##,##,## into an item inside of a List? So when I select that item, I can use the data part and for example, display it in a messagebox, or a textbox?

For example
"CD Drive 1" would be shown in the List, but 0,1,0 would be in the data part
"CD Drive 2" would be shown in the List, but 0,2,0 would be in the data part

Extracting Decimal Part Of A Real Number
Hi,

Does anyone know how to extract the decimal portion of a real number, is there a function i.e.

100.25

I only want the .25 part.

I want to perform a simple calulation and then add (concatanate) the result to the integer part of the entire number.

I thought here might be some fucntion which can extract without the need for using Mid or Left/Right fucntions.

Thanks,

Moben.

Thanks

Help On Finding Decimal Part Of A Double Number
I am having a mental blank

given a Double variable ... e.g.  DblPartDayAsPercent

and DblPartDayAsPercent = 4.44

Can somebody Please remind me how I work out then
two parts of the variable

eg   WholePart = 4

     Not Whole = 44


*very Bad Word* I can Not even remember  the correct termanology for the two parts of number ... and more I try .... blanker it gets !!!!!!!!


Eaassy Question,get The Real Part Of A Decimal Number
hi!!

I can believe I make this question:

How I get the real part of a decimal number??

250.09--------250

Thankxx!!

Getting Number Part Of &"11 High Street&"
I have an address string e.g. 11 High street.
I only want the 11 part. I would have thought there was a function that would convert the string into a number and only return 11 but I can't find one.

Does anyone have any ideas.

Fraction Format In VBA?
I created a dialog box driven worksheet and I need to know how I can enter a fraction into a text box and then have it subtract that amount from another cell. First I enter all the information into the text boxes and then I click OK. After clicking OK it updates certain cells in the worksheet. In one of the text boxes I want to enter in 1/2 and then when I click OK I want that number (1/2) to be subtracted from another cell. I get an error as if it doesn't understand that the 1/2 is a number and not text. If I enter the fraction in decimal form, it will work (.5 instead of 1/2), but I need it to work with both fractions and decimals. The cells themselves are formatted to fractions.

Example:

Range("L4").Select
ActiveCell.Value = TxtBANKWIDTH
Range("L5").Select
ActiveCell.Value = TxtBANKHEIGHT

Worksheets("sheet1").Columns("L").NumberFormat = "fraction"
Range("L4").Select
ActiveCell.Value = Range("L4") - Range("L11")
Range("L5").Select
ActiveCell.Value = Range("L5") - Range("L11")



In this example the value of cell L11 is 1/2. This just a portion of the program.

Multiply By Fraction
I'm trying to get the volume of a sphere but the problem is I have to multiply by 4/3 to get the answer. If I just use 1.333 / 1.34 its not the exact answer. How would I go about doing this getting an exact answer.

To make things easier I have done the rest of the math but It leaves me with 1 label to multiply by.


Code:
lblAnswer.Caption = lblR3.Caption * 4/3??

Float To Fraction
Hi,
I am looking for hint, algorithm that would help me to change a floating value to a fraction (multiplier divisor) as per example

0.005 => 1/200 easy to do as 1/0.005 = 200; so Multi = 1 and Div = 200
But
1.25 => 5/4
Any one has a clever idear or multiplying 1.25 X time until the result is an integer is my only option

Thanks

Fraction Question
hi,

Can I store fractions in access or sql database? If no, can I convert the decimal to fraction to display in Flexgrid VB?

thanks

Fraction Issues
Hello
I was about to implement variables using fractions in VB.
are there any pitfalls that i should watch out for? i mean comparisons, variables which might render the fractional part of the variable redundant and cause say a 40.001 to be equal to 0.001

Simplify A Fraction
I need to know how to do this in VB code. :P

Fraction Gets Converted To #
Hi,
I am a newbie in VB.
Using C++ FileWriter , I write a VB file (ie, a file with an extension .cls). I pass a string which has a decimal no. like 10.0 or 10.00 . In the generated VB file, the number comes as 10# in both the cases. While if I write 10.01, it comes properly as 10.01.
What should I do to avoid the conversion of the mantissa part to # ?

Thanks,
Nawal Lodha.

How I Can Use Fraction,Power In VB
I want to create a database of quarduatic eq .
for example
x^2+2x+(3/2)

How can I do this?

I Will be thankful for your help folks!

milepearl

Decimal To Fraction
I want to write a program that will take a decimal with up to 4 places
and convert it to 1/16 ths. I can sort of do that with:

n = 375 * 16 / 1000
Print n; "/16"

I am planning to use an input box to enter the number with no decimal
point.
But I don't know how to get a count of the digits in the denominator.
I will also round off any results that have a decimal place. I need
to know how I can identify the number after the decimal so I can round
it up or down. Thanks

Excel - Fraction
Hi Friends,

I've a float number in a cell. I use "=FLOOR($G$22,1)" to get the integer part. Is there any way to get the FRACTIONAL part? Please help me.

Thanks
Srik

Substract Two Fraction
Hi friends,

I need some small help. How to subtract two fraction.
For eg ( 22 1/2 - 20 3/4 = result is 1 3/4).
how can we achieve the output. Please try and let me know the output as early as possible.

Thanks

Turn A Decimal Into A Fraction?
Is there a built in feature to make decimals into fractions? I"m making a program for a cabinet maker, and the variables will have to be in fractions....is there an easy way to do this? Thanks ahead of time.

Decimal/fraction Conversion
i need to evaluate a number and determine if it contains a fraction. if it does, i need to convert it to a decimal value. pretty easy huh??? well im not sure what to do. i was thinking about the InStr() to determine if there is a slash in the string, and if so read the values to either side of it 1 digit at a time until i reach a space. can anyone please help me???

_-_-KiCkInIt-_-_

"**** the torpedoes, full speed ahead!!!"

VBScript Decimal To Fraction
Hi, Below is some VBscript/Html code which takes 2 fractions and adds, multiplies, subtracts and divides. What i can't get working is converting the decimal to fractions. If anyone could help me out it would greatly appriciated.
Thanks

<?xml version = "1.0"?>
<!DOCTYPE html PUBLC "-//W3C//DTD XHTML 1.0 transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
<title>Exercise 24.13</title>
<script type = "text/vbscript">
<!--

Option Explicit

Class CRational
    Private mNumerator, mDenominator, mNumerator2, mDenominator2
    Dim total, totalf

    Public Property Let firstNumerator(fn)
        mNumerator = fn
    End Property

    Public Property Get firstNumerator()
     firstNumerator = mNumerator
    End Property

    Public Property Let firstDenominator(fd)
        mDenominator = fd
    End Property

    Public Property Get firstDenominator()
     firstDenominator = mDenominator
    End Property

    Public Property Let secondNumerator(sn)
        mNumerator2 = sn
    End Property

    Public Property Get secondNumerator()
     secondNumerator = mNumerator2
    End Property

    Public Property Let secondDenominator(sd)
        mDenominator2 = sd
    End Property

    Public Property Get secondDenominator()
     secondDenominator = mDenominator2
    End Property

    Public Function addition()
        total = (CInt(mNumerator) / CInt(mDenominator)) + (CInt(mNumerator2) / CInt(mDenominator2))
        totalf = fraction(total)
        addition = "Addition:" & vbcrlf & total & space(6) & totalf
    End Function

    Public Function subtraction()
        total = (CInt(mNumerator) / CInt(mDenominator)) - (CInt(mNumerator2) / CInt(mDenominator2))
        totalf = fraction(total)
        subtraction = "Subtraction:" & vbcrlf & total & space(6) & totalf
    End Function

    Public Function multiplication()
        total = (CInt(mNumerator) / CInt(mDenominator)) * (CInt(mNumerator2) / CInt(mDenominator2))
        totalf = fraction(total)
        multiplication = "Multiplication:" & vbcrlf & total & space(6) & totalf
    End Function

    Public Function division()
        total = (CInt(mNumerator) / CInt(mDenominator)) / (CInt(mNumerator2) / CInt(mDenominator2))
        totalf = fraction(total)
        division = "Division:" & vbcrlf & total & space(6) & totalf
    End Function

    Public Function fraction(value)
     Dim holderValue, numerator, denominator, x, i, holdnum, holdden
     denominator = 1
     holderValue = Len(value) - 1

     For i = 1 to holderValue
         denominator += "0"
     Next

     numerator = value * denominator

     for x = 1 to numerator
     If numerator Mod x = 0 And denominator Mod x = 0 Then
         holdnum = numerator / x
     holdden = denominator / x
     End If
     Next

     Fraction = holdnum & "/" & holdden
    End Function

End Class

Sub cmdAdd_onClick()
    Dim ReftoCRational
    Set ReftoCRational = new CRational
        With ReftoCRational
            .firstNumerator = Document.Forms(0).textbox1.Value
            .firstDenominator = Document.Forms(0).textbox2.Value
            .secondNumerator = Document.Forms(0).textbox3.Value
            .secondDenominator = Document.Forms(0).textbox4.Value
            Call MsgBox(.addition())
        End With
End Sub

Sub cmdSubtract_onClick()
    Dim ReftoCRational
    Set ReftoCRational = new CRational
        With ReftoCRational
            .firstNumerator = Document.Forms(0).textbox1.Value
            .firstDenominator = Document.Forms(0).textbox2.Value
            .secondNumerator = Document.Forms(0).textbox3.Value
            .secondDenominator = Document.Forms(0).textbox4.Value
            Call MsgBox( .subtraction() )
        End With
End Sub

Sub cmdMultiply_onClick()
    Dim ReftoCRational
    Set ReftoCRational = new CRational
        With ReftoCRational
            .firstNumerator = Document.Forms(0).textbox1.Value
            .firstDenominator = Document.Forms(0).textbox2.Value
            .secondNumerator = Document.Forms(0).textbox3.Value
            .secondDenominator = Document.Forms(0).textbox4.Value
            Call MsgBox( .multiplication() )
        End With
End Sub

Sub cmdDivide_onClick()
    Dim ReftoCRational
    Set ReftoCRational = new CRational
        With ReftoCRational
            .firstNumerator = Document.Forms(0).textbox1.Value
            .firstDenominator = Document.Forms(0).textbox2.Value
            .secondNumerator = Document.Forms(0).textbox3.Value
            .secondDenominator = Document.Forms(0).textbox4.Value
            Call MsgBox( .division() )
        End With
End Sub
-->
</script>
</head>
<body>
<form action="">
<p>Enter First Numerator: <input type="text" name="textbox1" size="5"><br></p>
<p>Enter First Denominator: <input type="text" name="textbox2" size="5"><br></p>
<p>Enter Second Numerator: <input type="text" name="textbox3" size="5"><br></p>
<p>Enter Second Denominator: <input type="text" name="textbox4" size="5"><br></p>
<input type= "button" name="cmdAdd" value="Add">
<input type= "button" name="cmdSubtract" value="Subtract">
<input type= "button" name="cmdMultiply" value="Multiply">
<input type= "button" name="cmdDivide" value="Divide">
</form>
</body>
</html>

Convert Single To Fraction For EM_SETZOOM
I have a third-party print preview control that can zoom to show the whole page on-screen. It also has a .Zoom property that returns the current zoom level (e.g. 0.111742424242424 for near 11% zoom). I'm trying to get a RichTextBox control over a position on the page to mimic editing the document directly, and then set the zoom level of the RTB to the same zoom level as the preview control. Positioning has been no problem, but the zoom level has been tricky.

The EM_SETZOOM message for the RTB takes 2 parameters for its zoom level: the numerator and the denominator. Each number must be between 1 and 64. Do any of you know a way to convert a Single data type, such as 0.111742424242424 to the nearest fractional equivalent (i.e. 1/9)?

Right now I am just looping through all 4096 permutations of 1/64 to 64/1 in order to find the closest match. It works, and seems reasonably fast on my computer, but it just *feels wrong*!

Thanks in advance,
JPB

Mathematical Fraction In A Rich Textbox
Hi everybody,
Im writing a mathematic program at the moment. But I dont know how to make a two-lined fraction in a Rich Textbox. Can anyone help me, please?

Help To Put Precision In Fraction Inches Code?
Hi everyone?

As a European ive never used the inches fractions of the imperial unit system.

And what i want to is add precision to the inches fraction system:
-So what precisions do i have for the factions?
-And is there some VB example code of fraction inches with precision?

thanks a lot,for everyone help.

Decimal-&gt;Fraction (Brain Is Not Working)
Hey all,

Can somebody help me out here? This should be really easy, but my brain is fried, and I can't seem to get the damn thing back online

I need to be able to convert some decimal values to fractions, but they need to be converted to specific bases - 12 and 32 to be precise (which equates to picas and inches......when, oh, when will the US get with the program and move to decimal...)

Actually, if you're feeling particularly helpful, i really just need functions that will convert number like "2p5.5" to 2.45833 (p is for pica, so it 2 and 5.5/12ths), or 6i15 to 6.46875 (i is for inches, so it 6 15/32ths), and then convert back again....

I hate writing PageMaker plugins....

This should be really straightforward, and I generally don't post stupid questions, but occaisionally my brain just stops. My apologies...

Cheers

- gaffa

Excel To Access ,,part By Part
Hi Friend ,
Iam Got a project in Visual basic
Iam facing a following diffucialty

1. I want to transfer my data in Access from excel from field to field in a runtime mode,and data should be merge in part by part
Means :
I created a project in access and data should merged from weekly day by day as my client manualy give me a data(in excel) and i integreate in access

Kindly plz help me Friend ,Iam not so strong in Coding and sorry for my poor English

Update The Application Part By Part
Hello
I developed a VB6 program and its very big and I cannot send complete updates via internet every time.

I see big programs update partly.
Can I make some changes to my project and make it update via internet part by part as needed?

What is the main Idea to do it?
Where is the start point?
Is it posible and easy to change a project to be like that ?

Thanks

Writing A Program Computes The Number Of 1 Bits In A Given 32-bit Integer Number
I completed the program. I wanted to delete this post

Is There Any Built In Method To Convert Decimal Number To Binary Number In V.b 6.0
Hi everybody!

can u say whether any built in method is available to convert a given decimal number to binary number?


i can develope a user defined method for this. but i think it takes some extra time to execute... since i have to call this method repetedly...

thank you,
Regards:
raghunadhs.v

Text1 Number &gt; Text2 Number Error After 2 Digis Use(solved)
Umm, this a weird error it I amtrying to compare two numbers in each box,

so it will be something like this

If text1 > text2 then
msgbox "too large"
End if

But the weird thing is after the number hit two digits lets say over 10 and up then I get errors, even if the number in text2 is larger this only happens after it goes over 10

weird is there a better wayt to compare number that is more reliable or do i need to add something to the code

Thanks

Retrieve Hard Disk Serial Number Using VB [Not Volume Number]
I need help in reading the Hard Disk Serial Number [Not the volume number] using VB. Currently I am using VB5.

I have found a site that has the program to read the serial number but it is written in C++.

Can anyone convert it to a DLL or has any other solution for it.

The site is http://www.winsim.com/

Thank you.

Random Percentage Subtracted From Whole Number Mixed With Exact Number From A DB. Oh My!
Hey all, I have a more of how to question I have some code but I do not think its worth posting. I have a need some help with some code that would take a number "11192" to repersent 4 parts of something, but they need to be random parts of the whole. Then once I have that number, I query a DB randomly to get numbers to to = the random 1/4 of the whole number.

so lets say I have a list of numbers like

4.25
6.1
5.5
7
8.95
ect..

so I have all these little exact numbers that need to match this exact random 1/4 of the whole number.
Does this make since??? I have been working on this for a while now and I am not sure if I am making since! lol

How To Find Hard Disk Model Number & Microprocesser Number?
How to find hard disk model number & microprocesser number.
Is there any API through which I can find out these numbers.

Convert A Number Strored As Text To A Number Automatically!
Hi!

its possible convert a number strored as text to a number automatically,without lossing the non decimal number!!!?

thanks

Number Verses Auto Number - With An Add/Update Query.
Hi there,
I would like to use Number and NOT the normal AUTO NUMBER. But I have a mayor problem as always the same error message comes up and therefor I can't SAVE the data.

Would anybody be able to help.

Thanks aktell

Runtime error'-2147467259(80004005)':
Operation must use Updateable query.


Code:
Private Sub ctl_GButton4_Click()
'---
'--- SAVE.
Set Cmd = New ADODB.Command

With Cmd
.ActiveConnection = ConRost
.CommandType = adCmdStoredProc

If bAdd Then
.CommandText = "sp_Add_Rostering"
Else
.CommandText = "sp_Edit_Rostering"
'--- Originaly used with Auto Number.
' .Parameters.Append cParam("@iBookingDate_ID", _
adInteger, Rs_Rostering.Fields("BookingDate_ID"))
End If

'--- The first line I used as I like to use NO AUTO NUMBER, but use _
NUMBER as ID field.
.Parameters.Append cParam("@iBookingDate_ID", adInteger, _
SetText(Me.txt_BookingDate_ID.Text))
.Parameters.Append cParam("@iClientID", adInteger, _
SetText(Me.txt_ClientID.Text))
.Parameters.Append cParam("@sClientName", adVarChar, _
SetText(Me.txt_NameRostClient.Text), 50)
.Parameters.Append cParam("@iCarerID", adInteger, _
SetText(Me.txt_CarerID.Text))
.Parameters.Append cParam("@sCarerName", adVarChar, _
SetText(Me.txt_NameRostCarer1.Text), 50)
.Parameters.Append cParam("@iBookingTime_ID", adDBTime, _
SetText(Me.txt_BookingTime_ID.Text))
.Execute
End With

Rs_Rostering.Requery
bAdd = False

'--- Date for the grid.
Set Me.DataGrid1.DataSource = Rs_Rostering

End Sub

Private Sub GetValues()
With Me
.txt_BookingDate_ID.Text = _
GetText(Rs_Rostering.Fields("BookingDate_ID"))
.txt_ClientID.Text = GetText(Rs_Rostering.Fields("Client_ID"))
.txt_NameRostClient.Text = _
GetText(Rs_Rostering.Fields("ClientName"))
.txt_CarerID.Text = GetText(Rs_Rostering.Fields("Carer_ID"))
.txt_NameRostCarer1.Text = _
GetText(Rs_Rostering.Fields("CarerName"))
.txt_BookingTime_ID.Text = _
GetText(Rs_Rostering.Fields("BookingTime_ID"))
End With
End Sub

Code:
sp_Add_Rostering:

PARAMETERS [@iBookingDate_ID] Long, [@iClientID] Long, _
[@sClientName] Text ( 50 ), [@iCarerID] Long, [@sCarerName] _
Text ( 50 ), [@iBookingTime_ID] Long;
INSERT INTO tbl_June ( BookingDate_ID, Client_ID, ClientName, _
Carer_ID, CarerName, BookingTime_ID )
VALUES ([@iBookingDate_ID], [@iClientID], [@sClientName], _
[@iCarerID], [@sCarerName], [@iBookingTime_ID]);


[color=Red]sp_Edit_Rostering:[/COLOR]

PARAMETERS [@iBookingDate_ID] Long, [@iClientID] Long, _
[@sClientName] Text ( 255 ), [@iCarerID] Long, [@sCarerName] _
Text ( 255 ), [@iBookingTime_ID] Long;
UPDATE tbl_June Set tbl_June.Client_ID = [@iClientID], _
tbl_June.ClientName = [@sClientName], tbl_June.Carer_ID = _
[@iCarerID], tbl_June.CarerName = [@sCarerName], _
tbl_June.BookingTime_ID = [@iBookingTime_ID]
WHERE (((tbl_June.BookingDate_ID)=[@iBookingDate_ID]));

Convert To Number The Number Stored As Text In Excel
can anyone help me on how to convert the number stored as text in excel when i exported my recordset in excel

this is how i exported my recordset
objExcel.Cells(2, 1).CopyFromRecordset ADODBRecordset

Copyright 2005-08 www.BigResource.com, All rights reserved