INT function in VB6

Hello,
I am not sure that  this is the correct place to put VB6 question or not,
If not please suggest me correct one.
My Question:
Can any one explain me how INT function works internally for double type data in below case?
Eg.  Dim dblVal as Double
dblVal = 3.275
TextBox1.Text = Int(dblVal * 100 * 10)
Problem :  dblVal * 100 * 10 gives me 3275 but Int(dblVal * 100 * 10) give me 3274.

"Problem :  dblVal * 100 * 10 gives me 3275 but Int(dblVal * 100 * 10) give me 3274."
That's because the Int() function truncates the fractional part of the result. You may think the result of evaluating dblVal * 100 * 10 is exactly 3275, but in a computer, real numbers are approximations. The internal result may be 3274.99999, and the Int()
function gets rid of the .99999.
As far as VBB6 questions are concerned, VB6 is long out of support and no MSDN forums support VB6. Other sources of VB6 help:
http://forums.codeguru.com/forumdisplay.php?4-Visual-Basic-6-0-Programming

Similar Messages

  • MDX - Int function

    How to use INT() function with mdx?
    I'm trying to run the Int(104.504) function from EAS (essbase administration services console - file\editors\mdx script editor), exactly the same that is in the Oracle tech ref guide, but I keep getting a sintax error. What am I doing wrong?

    You're welcome - that's interesting.  This works for me in Sample.Basic:
    WITH MEMBER Measures.TestFunction AS 'Int(Sum(Children([Profit])))'
    SELECT {Measures.TestFunction} ON COLUMNS
    FROM Sample.Basic
    I think Essbase doesn't like the multiple levels in your WITH specification.  Measure.Profit.TestFunction doesn't work for me either, for example.
    The WITH clause sets up a 'virtual' member - it makes sense to think of it as belonging to a dimension, but it doesn't really make sense to think of it as having any particular position in that dimension.  Even if it was valid syntax, there would be no difference between Measures.TestFunction and Measures.Profit.TestFunction.  Metadata functions such as Parent don't work with calculated members - at least, not according to the MDX With Section entry in the Technical Reference.

  • How to unrigister the call back function,in vb6 with DAQmx 8.5

    I use daqmx api which named DAQmxRegisterEveryNSamplesEvent to register my call back function,When I invoke the function  DAQmxErrChk (DAQmxStopTask(taskHandleAnalog)) to stop my Task.then i call the procedure AD_OPEN  again,it raise an error ,tell me that i need to unregister the event,the data has transfer into the buffer.how can i unregister the event,please look at the following code.
    Spoiler (Highlight to read)
    Private Sub create()
       Dim channel As String
        Dim minVoltage, maxVoltage As Double
        Dim samplesPerChannelPerRead As Double
        Dim sampleMode As Long
        Dim boolVal As Boolean
        On Error GoTo AdErrorHandler:
        ' Get values from UI controls
        channel = "Dev2/ai1:2"
        minVoltage = -10
        maxVoltage = 10
        samplesPerChannelPerRead = 100
         If (taskHandleAnalog <> 0) Then
             DAQmxErrChk (DAQmxStopTask(taskHandleAnalog))
            DAQmxErrChk (DAQmxClearTask(taskHandleAnalog))
            taskhandle = 0
        End If
        ' Configure the task
        DAQmxErrChk (DAQmxCreateTask("", taskHandleAnalog))
         DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleAnalog, "Dev2/ai0", "", DAQmx_Val_InputTermCfg_RSE, minVoltage, maxVoltage, DAQmx_Val_VoltageUnits2_Volts, vbNullString))
        DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleAnalog, channel, "", DAQmx_Val_InputTermCfg_Diff, minVoltage, maxVoltage, DAQmx_Val_VoltageUnits2_Volts, vbNullString))
    End Sub
    Private Sub AD_Open()
        DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleAnalog, "", 200, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_ContSamps, samplesPerChannelPerRead))
        'Find number of samples specified
        DAQmxErrChk (DAQmxGetTaskNumChans(taskHandleAnalog, numChannels))
        'Configure Event Callbacks
        DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandleAnalog, 1, 4, 0, AddressOf EveryNSamplesEventHandler1, Nothing))
     ReDim dataBuffer(numChannels * samplesPerChannelPerRead - 1)
        ' Start the DAQmx Task
    '    DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandleAnalog, "/Dev1/PFI2", DAQmx_Val_Edge1_Falling))
        DAQmxErrChk (DAQmxStartTask(taskHandleAnalog))
        ' Update UI
        Exit Sub
    AdErrorHandler:
        MsgBox Err.Description
    End Sub

    This may be a bit late, so hopefully you found this on your own. But in order to unregister the event pass a null value for the callback function parameter in the DAQmxRegisterEveryNSamplesEvent function (Nothing in VB).
    National Instruments
    Product Support Engineer

  • Call function, pass value, access variable in movieclip class from main stage

    i am new to flash as.
    I got quite confused on some problems. as the function here
    is quite different from c and asp.net.
    I have a movieClip named MC, and it's enabled with action
    script, with the class name MC_Rectangle
    and a Stage.
    I override the MC_Rectangle class file in a mc_rectangle.as
    external file.
    here is the code:
    package{
    import flash.display.*;
    import flash.events.*;
    public class MC_Rectangle extends MovieClip {
    var sequence:int = new int();
    function setSequence(data:int):void{
    sequence = data;
    function addSequence():void{
    sequence ++;
    I have new a object in the main stage var
    mc_rect:MC_Rectangle = new MC_Rectangle()
    question:
    in main stage:
    1. how can i access the variable "sequence" in "mc_rect"
    2. how can i pass parametre from main stage to mc_rect via
    function setSequence(data:int)?
    3. how can i call the function in addSequence() in mc_rect.
    in asp.net, i usually use mc_rect.sequenct,
    mc_rect.setSequence(data), mc_rect.addSequence() to achieve my
    goals......
    btw, can function in mc_rect return out result to main stage?
    thanks in advance.

    Your as-file must be named MC_Rectangle.as (same upper/lower
    case as in the Class name)
    Ad 1) You have to declare sequence as a public property
    "public var sequence;" or - better - define a getter-function for
    sequence.
    Ad 2) mc_rect.setSequence(8); e. g. (you must write "public"
    in the Class-declaration of setSequence)
    Ad 3) mc_rect.addSequence(); e. g. (you must write "public"
    in the Class-declaration of addSequence)
    ... and yes, your methods can return a value: Replace "void"
    with the proper data type (int, String, ...) and place a "return
    myNumber;" or the like in the method's body.

  • (New to C# here) What is the best way to return false in a function if it cannot be executed successfully?

    In Javascript or PHP you can have a function that could return, for example, a string in case of success and false in case of failure.
    I've noticed (in the few days I've been learning C#) that you need to define a type of value that the function will return, so you need to return that type of value but in case of failure you can't return false.
    What is the best way to achieve this behavior and is there an example I can see?
    Thank you in advance,
    Juan

    Juan, be aware that returning null won't work with value types, such as an int, which can't be null. You'd have to use a nullable value type. A nullable int would be declared with a "?", such as:
    int? someOtherFunction(int param)
    if(something goes great)
    return param * 42;
    return null;
    And you have to use it like this:
    int? result = someOtherFunction(666);
    if (result != null) // you can also use result.HasValue
    // it worked, do something with the result
    // if you're doing math with the result, no problem
    int x = result * 2;
    // but if you're assigning it to another an int, you need to use this syntax
    int y = result.Value;
    Before nullable value types came along, for a method that returned an int, I'd use a value of something that wouldn't normally be returned by that method to indicate failure, such as a -1.
    ~~Bonnie DeWitt [C# MVP]
    That's something very very important to keep in mind. Can save you from a lot of headaches!
    So if you have an int function and it might return NULL, if you are doing Math with the return value you can use it directly, but if you're assigning it to another variable you have to use .Value?
    Thanks

  • Variable Function Names

    What I'm trying to do is add event listeners for each position up to the total of compPositions. This way, each one will have a dymanic function name. Right now, they all launch function "clicked1" but I can't figure out how to make it add numbers to the function name dynamically. Is there a different method I should be using to accomplish this goal?
    Right now, compPosition = 5 so it should create 5 event listners, but I want them each to have their own function they exucute.
              var i;
              for (i = 1; i < compPositions +1; i++)
                        currentPos = "pos" + i;
                        this["pos" + i].addEventListener(MouseEvent.CLICK, clicked1)
    Edit:
    Actually, after thinking about it, I think this is a better approach, but I'm not sure how to pass over a variable using a click event.
                var i;
                for (i = 1; i < compPositions +1; i++)
                      var currentPos; //now it's private to this for loop
                      currentPos = "pos" + i;
                      this["pos" + i].addEventListener(MouseEvent.CLICK, posClicked)
    In this version, I just need to pass over the currentPos variable to the function, but I'm not sure if that's possible.
    Thanks,
    Corey

    Before solving, I would caution why you need them to have a unique function/unique function name. You should be able to have them all hit the same function and do different logic within depending on the target.
    That aside, you could do something like this:
    for (i = 1; i < compPositions +1; i++)
              currentPos = "pos" + i;
              this["pos" + i].addEventListener(MouseEvent.CLICK, this["clicked" + i])
    However, you would have to manually define each function. Alternatively, you can use closures:
    for (i = 1; i < compPositions +1; i++)
      currentPos = "pos" + i;
      this["pos" + i].addEventListener(MouseEvent.CLICK, getFunction(i))
    function getFunction(i:int):Function
              return function(e:MouseEvent):void { trace("Clicked " + i); };
    EDIT:
    Using the closure method you could also pass the current pos if you needed to:
    for (i = 1; i < compPositions +1; i++)
      currentPos = "pos" + i;
      this["pos" + i].addEventListener(MouseEvent.CLICK, getFunction(i, currentPos))
    function getFunction(i:int, currentPos:String):Function
              return function(e:MouseEvent):void { trace("Clicked " + i + " currentPos = " + currentPos); };

  • Calling a function that's inside another function

    function test1():void
         function test2():void {..}
    How do I call test2 function (outside test1 function)? Is it possible?

    Hi,
    yes it is possible.
    Here is the code helps u
    function foo():Function
    var x:int = 40;
    function rectArea(y:int):int // function closure defined
    return x * y
    return rectArea;
    var myProduct:Function = foo();
    var s = myProduct(4);
    trace(s);
    Saransoft

  • Open Blocks with ordinal number with VB6

    nifOpenBlock (nifDesc_t ud, NIFB_ORDINAL(n),
    nifDesc_t *out_ud)
    How can I create NIFB_ORDINAL macro or routine in VB6. I nedd to open the blocks using the ordinal number not the tag name.

    Please refer to VC code, the macro NIFB_ORDINAL is defined from function makeIndex. You also can find this function in VB6.
    Feilian (Vince) Shen

  • Question about StartPCSound() function

    Hi all,
      I am using StartPCsound( unsigned int ) function  in my coding and i want to acquire
      voltage from the audio signal generated by this function.
      Is this practically possible to extract the voltage?
      Any help will be greatly appreciated.

    Hi again
       Please correct me if i am wrong that the StartPcSound ( ) function generates the BEEP by means of buzzer
      or speaker on the mother board.
      When i try to see this signal on Oscilloscope on the  " LINE OUT "  pin of audio connector, nothing appears on 
     oscilloscope. Why?
     Is there any way to Route this generated BEEP signal to the LINE OUT pin? So that it can be seen
     Thanks.

  • Function overloading on return types

    consider following two overloaded functions
    public int functionA(int a,int b);
    public char functionA(int a,int b)and if i call them like this
    int returnInt = functionA(a,b)
    char returnChar = functionA(a,b)in this scenario which function to call can be decided depending on the
    return type then why java don have overloading on the basis of return type ?

    Try it.

  • How to make a function in separate thread

    i need to make a function that is running in a separate thread
    Thank's in advance

    Thank's
    but in my program i have a main class which is a server it runs forever.
    from the main class when i call a function it runs in a separate thread and returns the result to the callee and the main function continue it's work
    class server
    //this function when called must be in separate thread
    public int function(int x)
    //there could be wait here or sleep
    return x*2;
    public static void main(String[] args)
    // Run RMI server
    i hope u understand me!!!
    Thank's

  • Oci oracle8i - how do oci to pass a varray parameter to a function

    How do oci to pass a varray parameter to a function?

    don't declare a variable inside a function body unless you want it to be local to that function/function call.  ie, use:
    var cont:int;
    function whatever(){
    cont=whatever;

  • Debugging a MOUSE_DOWN function

    I have an animation im working on, a series of images, placed in individual keyframes, that is rotatable by clicking down and dragging left or right.
    My actionscript is solid when viewed in flash's desktop player. The problem is the client views it in whatever web browser he uses, and when viewed in a web browser, the MOUSE_DOWN action causes the image to progress without regard to the mouseX rule.
    This is making me pull my hair out, so here is my code, any help would be appreciated:
    stop();
    stage.addEventListener(MouseEvent.MOUSE_DOWN, mDown);
    stage.addEventListener(MouseEvent.MOUSE_UP, mUp);
    var prevMouseX:int;
    function mDown(event:MouseEvent):void {
    prevMouseX = stage.mouseX;
        this.addEventListener(Event.ENTER_FRAME,mMove);
    function mUp(event:MouseEvent):void {
        this.removeEventListener(Event.ENTER_FRAME,mMove);
    function mMove(event:Event):void {
            var activeMouseX = stage.mouseX;
            if (activeMouseX > prevMouseX){
                if(currentFrame == 1){
                    gotoAndStop(totalFrames);
                } else {
                    prevFrame()
            if (activeMouseX < prevMouseX){
                if(currentFrame == totalFrames) {
                    gotoAndStop(1);
                } else {
                    nextFrame()
    prevMouseX = stage.mouseX;

    use the trace function to debug.

  • Need help using basic interger function

    I made a basic program to calculate the arrival of a trail, but the problem
    is that when i get the result of sum6 it comes out as 13.833333333333333.
    I just want to remove all the numbers after 13 for the printout answer?!?!!?!
    I know i have to use the "int" function to do this, but where & what do i put
    in my code to do that?
    thanks!!!!
    // DECLARE VARIABLES/DATA DICTIONARY
    double num1,num2, num3, num4 ; // Given numbers
    double sum1,sum2, sum3, sum4, sum5, sum6, sum7, sum8 ; // Intermediate, sum of num1, num2, and num3
    // READ IN GIVENS
    System.out.println ("Please enter hour value of start time: ");
    num1 = ITI1120.readDouble( );
    System.out.println ("Please enter minute value of start time: ");
    num2 = ITI1120.readDouble( );
    System.out.println ("Please enter the speed of train (in km per hour) : ");
    num3 = ITI1120.readDouble( );
    System.out.println ("Please enter travel distance (in km) : ");
    num4 = ITI1120.readDouble( );
    // BODY OF ALGORITHM
    sum1 = num1 * 60;
    sum2 = sum1 + num2;
    sum3 = num3 / 60;
    sum4 = num4 / sum3;
    sum5 = sum2 + sum4;
    sum6 = sum5 / 60;
    sum7 = sum6 * 60;
    // PRINT OUT RESULTS
    System.out.println("The hour value of the arrival time is: " + sum6);

    Which is easier to debug, your code with the generic variable names or this code:
        System.out.println ("Please enter hour value of start time: ");
        startHour = ITI1120.readDouble( );
        System.out.println ("Please enter minute value of start time: ");
        startMinutes = ITI1120.readDouble( );
        System.out.println ("Please enter the speed of train (in km per hour) : ");
        velocityKmPerHr = ITI1120.readDouble( );
        System.out.println ("Please enter travel distance (in km) : ");
        travelKm = ITI1120.readDouble( );
        startMinutesFromHours = startHour * MINUTES_PER_HOUR;
        totalMinutes = startMinutesFromHours + startMinutes;
        velocityKmPerMin = velocityKmPerHr / MINUTES_PER_HOUR;
        travelTimeMinutes = travelKm / velocityKmPerMin;
        arrivalTimeTotalMinutes = totalMinutes + travelTimeMinutes;
        arrivalTimeHours = (int)(arrivalTimeTotalMinutes / MINUTES_PER_HOUR);
        noIdeaWhyYoureCalculatingThis = arrivalTimeHours * MINUTES_PER_HOUR;?

  • Why a classic asp + vb6 component application using MSXML6.0 is slower on W2K8 server compare to W2K3 server?

    Recently we moved classic asp application+ vb6 com components from W2K3 server to W2K8 server.
    The only change made in the vb6 component is upgrade from MSXML 2.0 to MSXML 6.0. These vb6 components are compiled into dlls and registered as COM components on the server.
    The issue we are facing right now is that asp pages are taking a lot of time to load.
    The functionality which used to take 8-10 sec is now taking around 40 seconds.
    We inserted the logs and found that all the functions in vb6 code which are related to MSXML 6.0 upgrade have caused the slowness in the application.
    On further research, we found that vb6 modules which uses 64 bit version of MSXML6.0(present under C:\Windows\System32) to load XML documents takes over two times longer to load an xml doc which uses 32bit version of MSXML6.0. (present under C:\Windows\sysWOW64)
    Microsoft has provided a hotfix for this. Please see below url.
    support.microsoft-com-kb-2799406
    We already tried this hotfix but it did not fixed the performance issue.
    Question:
    1) On W2K8 machine, we are unable to use MSXML6.0 present under C:\Windows\sysWOW64. Whenever we try to reference to this location it by default references back to C:\Windows\system32. We also opened the vb project file in a notepad and changed the reference
    location and opened the Project again but no success. Can anyone suggest what can be the probable solution to fix this?
    Current Scenario:
    Reference=*G{F5078F18-C551-11D3-89B9-0000F81FE221}#6.0#0#..WINDOWS-System32-msxml6.dll#Microsoft XML, v6.0
    Expected Scenario:
    Reference=*-G{F5078F18-C551-11D3-89B9-0000F81FE221}#6.0#0#..-WINDOWS-sysWOW64-msxml6.dll#Microsoft XML, v6.0
    2) Once we compile this vb6 code to a dll by having a reference to this sysWOW64 folder, how to ensure/confirm reference from Syswow64 will be picked up once it will be on W2K8 server?
    3) Also if you can suggest what can be other areas we should target/think of for resolving this performance issue?

    I have encountered the exact same problem with msxml6.dll that is described in the latter part of you statement. Had you come up with a possible solution?

Maybe you are looking for

  • Iphone not as good as touch ipod

    Looks like the iphone won't support TV out while all the newer ipods will. Quoted directly from the apple store for the apple AV cables. Note: Component video output to television is supported by iPod nano (third generation) and iPod classic at 480p

  • Send range as picture in email

    hey i have the below code which sends the range in the body of an email to the addresses specified in another range. I need to ammend it so the range is pasted as a picture to preserve formatting etc?? any help is always appreciated Tom Sub Managerma

  • Template disconected from site

    After relocating the directory of the site and recreating the site through Dreamweaver, the template does not update the site pages anymore. It seems as if it has lost its connection to the site. Is there a way to reassign the template to the whole s

  • Missing mail

    I have id'd 3 email contacts who do not receive my emails, ( they do show up in my sent mail), but I do not get a reject message.  They are on different networks (optonline, mindspring and me.com) using both PCs and macs.  If I send them an email fro

  • How can I download the Photoshop?

    When I try to download say: is a desktop app so you will want to download it from your computer... but I am in my computer, what happen? Hope your soon response. Thank you, Jennifer