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




Decimal Place


Hi i am trying to write a some code that will take a value and depending on the deciaml place round the value up. So if the value is say 1.7 i want it to stay 1.7 but if the value is 1.8 i want it to become 2.0. is there a function that anyone knows about that will isolate the number after the decimal place, for example like the Int function does to the number on the left of the decimal place?.

Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Label Of The Decimal Place
i set the label property as two decimal place.
when i load some double array into the label.
the label becomes the double array of the decimal place.
but actually, i just want two decimal place. how can i do that!

Inserting Decimal Place
I am displaying a 16-bit signal (data1) in a label as a caption from values 0 - 255, but I wish to insert a decimal place so it reads 0.0 - 25.5. I have tried Format(data1, "#0.00), which gives 0.0 - 255.0 but have not yet achieved the decimal place inserted into the data value. I require data1 and data2 to display in the same format. Can anyone help?


Code:

Private Sub Timer1_Timer()
Timer1.Enabled = False
Dim Channel As Long
Dim data1 As Long
Dim data2 As Long
ReadAllAnalog data1, data2
Label7.Caption = data1 & "m/s" 'displays numberical value of Data1
Label9.Caption = data2 & "°C" 'displays numberical value of Data2
Timer1.Enabled = True
Dim temp As Long
Dim data As Long
data = data1

End Sub

Rounding To 1 Decimal Place In Vb5
hiya
can anyone tell me how to round to one decimal place this is what i have so far....


Code:
Private Sub cmdStart_Click()

Dim Number As Single
Dim Result As Single

Number = InputBox("Please enter a number")

Result = CInt(Number)

txtResult.Text = Result

End Sub

Decimal Place In Calculator
how can I add the "." function to my calculator

Rounding To 1 Decimal Place
Hi, i did a simple division 40/3 and got 13.33333333 for answer.

How can i round off the 13.33 to the nearest 1 decimal place so i would get 13.5??

Adding A Decimal Place
Hi Guys,
I am looping through a database to get out a number of fields as follows.


Code:
Do While objRS_BULKED.EOF = False
Call genReport(strReportName, objRS_BULKED.Fields(0), objRS_BULKED.Fields(1), objRS.Fields(2), objRS.Fields(3), objRS.Fields(4), objRS.Fields(6))

objRS_BULKED.MoveNext
Loop

The problem that I have is that the first field that I call back is a money field. Some of the values that I get back are like £1000 even and somevalues that I get back are like £1000.24. How do I make all the values that I return have two decimal places. eg. If I get a value of £1000 I want this to appear as £1000.00

Thanks for your help
JK

Decimal Place Question
I would like to have results show in my txt box with no more than 2 places after decimal (0.00). I tried selecting the data format property on the txt box and setting it to how I would like, but it doesn't seem to do anything. Ideas?

Thank You! (again)

Decimal Place Length
hello. I am trying to make a program that will write out Phi (golden ratio). here is the code that i use:


Code:
Private Sub Form_Load()
Text1.Text = .5*sqr(5) + .5
End Sub




I know the equation works out to be Phi, which as I under stand is a 216 digit number. however the number that comes out in text1.text is only the first 15 digits. is there any way to make it divide out the full amount???



-Steve



PS If I am incorect about any thing to do with Phi or the Golden Ratio, tell me.

Decimal Place Of A Field
I'm writing a program that creates a table w/ three fields.  One of the fields is a currency field.  However, I want the currency field to say $10.107473.  I know that in design view in MS Access, you can edit the attributes of a currency field, but how do I do this w/ VB code?  Thanks
-Mike

Decimal Place As A Command Botton
how can I allow the user to enter a decimal place using a command bottom.

this is what i did for the numbers ex. #1

textbox = textbox & 1

Not Rounding But Only Displaying The First Decimal Place
I was wondering if there was a easy way to have vb remove everything off of the last decimal place?

Is there a built in function or does anyone have sumtin better that this?


VB Code:
Public Function TrimNum(curNumber as Currency, lngDecPlace as Long) as Currency Dim strTmp() as String strTmp = Split(cStr(curNumber), ".") TrimNum = cCur(strTmp(0) & "." & Left(strTmp(1), lngDecPlace)) End Function

Formatting Currency In 2 Decimal Place
Hi All,
Does anybody knows how to format currency in this mode "150.00" (2decimal place). I code it as



txtCharges = Format$("#####0.00") but it doesn't work. I get theanswer with "150" only.

Thanks.

Rgds,
Khai Sze

How To Display Zeros After Decimal Place (example 7.000)
Hi,
I set the text1 dataformat property as number with 3 decimal places.
For example if i enter 7.891 it is ok...
but
if i enter only 7 it is not displaying decimal places as 7.000
How to display zeros after decimal place(automatically or in text box lostfocus event).
regards,
MADHU

Special Case: Only 2 Decimal Place In Texbox
Hello All,

I know that this has been asked before and i did made a search but did not find the exact ans to my problem:

Actually, it is a simple one:

u have a textbox which must accept only numeric values --> that part is OK (that is allow only: 1 decimal point, vbkeybackspace, 0-9) thats in the keydown() event

Now, since i ll be dealing with prices , i must restrict the user to only 2 dp and i ve used the following code :


Code:
Private Sub txtDiscount_Change()
If Len(Mid(txtDiscount.Text, (InStr(txtDiscount, ".") + 1))) > 2 Then SendKeys "{Backspace}"

end sub

the problem with the above code is that it does not allow the user to input more than 2 digits EVEN before the decimal point, i.e. u cannot type 250. It prevents the zero from appearing

what i need is that it does not allow more than 2 digits AFTER decimal point.

So, i would be very grateful if u could help me out.

Thanks

Single Decimal Place, & Length Inaccuracy
Hey all, I'll cut to the chase here:
Code:

Code:
tempXpixels = Xpixels * Screen.TwipsPerPixelX 'convert to twips
tempYpixels = Ypixels * Screen.TwipsPerPixelY 'convert to twips
tempTotal = Int(Sqr((tempXpixels ^ 2) + (tempYpixels ^ 2))) 'merge for ease of use (pythagorean theorum)
tempTotal = tempTotal / 1440 'convert to inches
tempTotal = tempTotal / 12 'convert to feet
The problem is, tempTotal isn't accurate! I measure out one foot, using the above code, and it's quite a way over a ruler held up to the screen. Is that to be expected?

Another thing, is there a way to make a decimal with one or two fixed decimal places? Thanks.

Arigato,
Gamer X

Getting Just The 1st Decimal Place Of A Number To Hold Constant
im getting readings which are 4 decimal places long, and the last 3 decimal places are causing my system to go nuts!! anyone know how to hold the 1st decimal place constant and get rid of the last 3??

Fixed Decimal Place In Math Function
hi ,please help.i want to fixed decimal place to textbox value.i try to use round function but the value appear cannot display 3 decimal from the textbox,some of the value is round to become decimal place,i want all the value display is decimal .000

for example:
5.580 this is the result i want
5.58 this is the current value display

this is the current code:

Code:
C2 = Round(Val(n), (Val(dp) - 1)) + (Val(d) * 31)
text1.text = C2


thanks for help!

MSHFelxGrid - How To Format Data To 2 Decimal Place
Hi,

     I had a problem with MSHFlexGrid. I want to format the data displayed on the grid to have 2 decimal places, how can I do it?

     The data came from an access database and read through and adodc object. The adodc then becomes the DataSource for the MSHFelxGrid.

     Thanks for the help in advance.

Eddie

Fixing The Decimal Place Of Numeric Field At Runtime
Dear all,


I have to change the decimal places of a database field at runtime.

How can i use functions to write a script under format area.

I am using Crystal Reports 8.5 with VB 6 and SQL Server 2000


Thanks in Advance

Sam Alex

How To Copy The Complete Folder Fron Place To Another Place Using VB6
How to Copy the Complete folder fron place to another place using VB6 ...?

Insert SQL Statement With A Decimal Field When The Decimal Separator Is The Comma
Hi,
I have a problem with the “Insert” SQL statement in an Access program.
I have a table in which there is a numeric field of Single type, so it can contain decimal numbers. As I’m european, the decimal separator in the control panel (international and language options) is set to the comma “,” and not to the dot “.”
What happens is that, when I want to insert a new row to the table, Access thinks that a decimal number is two separate integer numbers, so it stops for a run-time error saying that the values’ number in the query doesn’t correspond to the destination fields’ one.
For example, suppose that the table is composed by two fields, the first one “intNumField" of Integer type, and the second one "singleNumField" of Single type.
I define and initialize two variables as follows:

Dim intNum As Integer
Dim decNum As Single

intNum = 4
decNum = 1,7 ' (or decNum = 1.7, it's the same)

The statement
DoCmd.RunSQL "insert into Numbers values (" & intNum & "," & decNum & ")"

becomes this one:
DoCmd.RunSQL "insert into Numbers values(4,1,7)"

You can see it defining a String variable as follows:
Dim str As String
str = "insert into Numbers values (" & intNum & "," & decNum & ")"

putting a breakpoint after this statement and checking "str" value.
The run-time error is obviously unavoidable.

Is there a way to let Access know that this one isn't a list of 3 integer numbers (4 and 1 and 7) but a list of 2 numbers, the first integer (4) and the second decimal (1,7)?

Thank you very much

How I Can Convert Decimal To Hexa Decimal??
Hi,
I want to convert a decimal to hexadecimal in VB.

the value is more than signed32 bit.

i got one code ConvertDecimalToHexadecimal(ByVal Value As Double) from internet which is also giving overflow error.

Can anyone take up this challenge to help me out.

the decimal number for which i need hex(the number is a random generated one) = 11783197335

I need a quick response.

Thank you in advance

How U Will Check Decimal And Non Decimal Values???
Hi Friends
Is anybudy know how to check that is there a decimal value on non decimal value in my text feild??

Thanks alot in advance

The Decimal Part Of A Decimal
Hi

How can I grab the decimal (non integer) part of a decimal number from a variable. The integer part I can do but I'm struggling to find a reference for other part.

e.g. 0.999 from 15.999.

Thanks in advance.

Yes, I am a newbie.

Sorry, wrong section I'm using VB .net

Where Is The Right Place
can you tell me please where is the right place for getting start with
VB game programming. or any easy tutorial for a novice in game programming. thnx very much

Name By Place
hi is it at all possible to have 2 values (x and y) and find out if there is an object with those values for top and left and if there is an object there whatis it called

Using ADO In The Place Of DAO
How can I implement a database connection in visual basic without using the default DAO connection?

I wish to use an ADO connection to connect to a Access 2002 database.

Is This The Right Place?
Hi ppl,

I’m not sure if this is the right place to post so please accept my apologies if it is not.

Simple question (but I guess a not to simple answer) Is it possible (and if so how) to use the lame.dll (not shelling to lame.exe) from a VB program?

Thanks in advance

Everso

Is This The Right Place?
I've recently re-installed my vb6 enterprise edition but the cd is damaged and the msdn component wouldn't install. is there anywhere I can download this or even just the help files from? ta.

sorry if this is the wrong section to ask in but i couldn't see anywhere else.

How To :- F5 In Place Of ALT-X :-)
Like, if the caption of a command button is say "E&xit" then Pressing Alt-X would produce an event of that button_click() now, what i want is to set ...say F5 to that exit button ...so from anywhere "Alt-X" can work then f5 should also prodece the same button_click event......please help me on this....

do i need to b more elaborate....

thanks
SA.CH.R

Out Of Place VBA ???
Sure it's not pure VB, but didn't know where else to ask. Does anyone know of a way to make it so that when I receive an email in outlook, it checks for something in the subject then saves all attachments in the file.

In other words

<VBCode>

if subject = "File from work." then
with thisMessage
.attachment.saveAs "C:workfile.exe"
.thisMessage.delete
end with
end if

</VBCode>

Of course this code is BS, just use it to understand what I mean.

In Place Of Global
Hi, I'm a beginner.... So i'm going to ask a lot of questions! Some of you may find this annoying, but its for a good cause. No really, it is...
So far I have typed down all of my data types, and have used the public variable in place of my Global variable. I was working from a site, and tried to use the global variable, but this caused an error. I am using Visual basic 4. Hmm. Maybe the code I have written will help, here it is:

Private Sub Form_Load()
Public Type IrvineArray ' Define the contents of the Character array
Name As String ' Character's name
X As Integer ' current X coordinate on map
Y As Integer ' current Y coordinate on map
MapNo As Integer ' current map number character is in
StrMax As Integer ' characters maximum strength
StrCur As Integer ' characters current strength
magMax As Integer ' characters maximum magic
magCur As Integer ' characters current magic
DexMax As Integer ' characters maximum dexterity
DexCur As Integer ' characters current dexterity
Luckmax As Integer ' Luck, maximum
Luckcur As Integer ' Luck, current
HitPtMax As Integer ' characters maximum hit points
HitPtCur As Integer ' characters current hit points
MagPtMax As Integer ' Max magic points
MagPtCur As Integer ' Current magic points
Punch As Integer 'what object number the sword is
Bulletproof As Integer ' what is left on the armour
WP As Integer ' how much gold the hero has
End Type
Public Irvine As IrvineArray ' create the Character array
Public IrvineInv(50) As Integer ' define the character inventory array

End Sub

Is this okay, and if it is not, what should I change it to, and where? Thank you for helping this coder! I am working from http://markbutler.8m.com/vb-tutorial.htm by the way.

Place A Toolbar
I want to place a small toolbar directly to the right of the standard toolbar in word. How do I do that?

Newbie Out Of Place?
ei, uh am starting out a school project about document management. we planned to use vb and word templates for documents with ceratin formats...

i have found a lot of really helpful stuff in this site about this and am now trying them out. got a none programming question though, can anyone direct me or share a site where i could find sample algorithms or methods in "indexing" and "keyword creation" for the documents to be handled by the edms? (keywords are like post-it notes on documents so rather than scanning the whole documents for a certain search, you just look at the post-it notes attached to it...something like that).

this might be off the line though but if anyone has anything to say, i will be more than grateful (and so are my groupmates).

How Do I Place The Cursor Where I Want
I have written a small program where I can take data from a database and copy it onto the clipboard. It is a small form so that it fits in the corner of the screen. I would like to paste that information onto say a word document that is on the rest of the screen. I need to be able to place the cursor at the correct place on the word document and then have the data pasted onto the word document. How do I control the cursor and then how do I paste the data?

Thanks in advance

Where Should I Place These Codes?
Hi all,

After searching through this forum, I got the following codes which can be used to add a command button in the command bar:


Code:
Dim NewButton As CommandBarControl

Set NewButton = CommandBars("Standard").Controls.Add(Type:=msoControlButton, Id:=2950, Before:=45)
I am trying to write a COM Add-in (for MS Word) using VB6 which will add a command button in the "standard" command bar and I got the following functions in the Add-in DLL file:


Code:
Private Sub AddinInstance_OnAddInsUpdate(custom() As Variant)
.................
End Sub

Private Sub AddinInstance_OnBeginShutdown(custom() As Variant)
.................
End Sub

Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
...................
End Sub

Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
...................
End Sub

Private Sub AddinInstance_OnStartupComplete(custom() As Variant)
....................
End Sub

Which of the above functions should I place the codes for adding the command button in the command bar?

I tried to place them inside AddinInstance_OnConnection or AddinInstance_OnStartupComplete but received the following error message when starting MS Word:

Run-time error '-214767259 (80004005)': Method '~' of object '~' failed


What should I do to resolve this problem?

Many thanks to you all!

How To Get A Exe To Place Inself
Fellow Forum users,

I am currently creating a program, and I wish it to be able to place itself inside the C:/Documents and Settings/All Users/Start Menu/Programs/Startup Folder

What and where could I put the code to do this. I think it maybe the Form_Load section

How Could I Place This In An Module.
Hi there,

How would I be able to place this Code in an .bas module. I seem to get always an Error Msg for the (Index) ???.

Thanks aktell GER/NZ



Code:
Private Sub CtlGButton2_Click(Index As Integer)
'---
Select Case Index
Case(0)
------------
Case(1)
------------ etc.
End Select

End Sub

Not The Right Place To Post This, But...
Cannot find any other forums to place this post, and can't find any info on this subject either.

All I need is for my asp-script(VB) to get a hold of a string in a table on a html-page.
Also, I have problems with the onclick event of a button in a HTML-page. What is wrong with this code:

<input type=button name=Button04-37708 value=04-37708 onclick=ClickedCase(04-37708) >

Anyone...??

In Place Of Form_Keydown...?
In a nutshell, this is what I want to do: whenever a user presses a key on the keyboard, frmConversation pops up, giving the user a window to type into, and send data from.

I already have frmConversation coded up and ready to go... but it seems as if it does not want to be called! Rather, form_keydown for the form it is called from refuses to register.

What can I use in it's stead?

Thankee kindly,
Mith

Click And Place Help
I am making this game, and i cant make click and place work.
I have 1 picture which i want to click, called: Tower1
I have an array of images in a grid, because i need the tower only to appear in a certain area, this aray is called: Grid(), 20 in array

What i want it to do is, i click the tower1 image then click one of the array images, then the array image will load the picture of the tower.

Is it also posible, that once ive clicked that a transparent image of a tower will follow my mouse?

Thx heaps for any input you guys have

Where Can I Place My Programs?
Hi! My name is Craig, and I would like to know, where can I place my programs (and a link) on a decent webpage with many visitors? I am happy to host them on my website. If you goto http://www.mynesoft.cjb.net, you can see some of my programs. Please check them out.

Craig - MyneSoft Manager.

Best Place To Get Controls?
I need controls that will allow me to interact with a WinCE device from my desktop. I've search everywhere, found some at vbce.com, and they're horrible (and also from 1999...). Any ideas where i can find these?

Place App In Background
Hi all,

I'm making an app that serves as a frontend to other apps, and (most of the time) when I launch the external apps from the program, they show up in the background - i.e. my frontend app is still in focus.

Is there a way to cause the external app to start up in focus? Or maybe to send the frontend app to the background (not minimize)?

Thanks,
Gabe

Where To Place Pop-up Of Code?
The code below handles the passing of a Text-box entry into an Access table. But, I need a pop-up to inform user of this when they hit the submit button. Like: "New account has been set-up" My question is this: where would that tiny piece of code go in the code below?

Private Sub cmdCreate1_Click()

If txtUsername1.Text = "" Then
MsgBox "Please enter a username and password", vbInformation

Exit Sub
End If

Dim goConn As New ADODB.Connection
Dim adoCmd As New ADODB.Command
Dim strConn As String, strSQL As String

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "/et.mdb;" & "jet oledb:system database=c:program filesmicrosoft officeofficesystem.mdw;jet oledb:database password=wardca;"

goConn.ConnectionString = strConn
goConn.Open
' Define a query string
strSQL = "INSERT INTO Users ([name], [password]) VALUES ('"
strSQL = strSQL & txtUsername1.Text & "', '"
strSQL = strSQL & txtPassword1.Text & "')"
' Set up the Command object
adoCmd.CommandText = strSQL
adoCmd.CommandType = adCmdText
adoCmd.ActiveConnection = goConn
adoCmd.Execute
' Tidy up
Set adoCmd = Nothing
goConn.Close
Set adoConn = Nothing

End Sub

Need A Place To Start
My instructor gave my class a chance to grab some extra credit by writing a small program. The catch is that when you execute the program, it is supposed to print the source code either to a printer or text file while it is executing. He says it's only a few lines of code, but I don't have the slightest clue of where to start in my research for the answer.

So, my question is: In order to accomplish this task, what is the command or API call that I will need to do this. I don't want anyone to write the code for me, just a keyword that will get me started researching for this project.

Any help will be greatly appreciated,

---2bNvUs---

Totals / Place
hi - this is probably quite simple, but i just don't get it right...

i collect some numbers from a database, and it looks something like this: 14 - 0 - 5 - 17 - 14 - 0 etc. etc.
i put this in a label array - lblTotals(i)
next i want to put the place each total has next to it, in another label array (lblPlace(i).

i get problems when there are two or more totals that is the same (here 14).

it should look like;
14 - 2. place
0 - 5. place
5 - 4. place
17 - 1. place
14 - 2. place
0 - 5. place

does this make any sense ?! any ideas are welcome /jon

Any Place Where All The Apis Can Be Seen?
Would like to know if there is a website or a sample project which shows the apis and its properties. I am interested in subclassing some controls of the visual basic.

Fix BrowseForFolder In Place
I am trying to get the Browse For Folders dialog to be fixed in place on my form.
The solution appears to be at vbAccelerator
http://www.vbaccelerator.com/home/VB...er/article.asp
However, if you stretch frmCapture and picCapture in the example on that site you end up with OK and Cancel buttons in the middle of the treeview.

Is anyone familiar enough with this example to understand how to remove those buttons?

Alternatively, would it be possible to put the standard SHBrowseForFolder API into an ocx so that it could be placed on forms?

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