C# :: Getting Real Number From A Textbox?

Oct 28, 2014

All I want is to let the user enter a value such as .55 or say, .34 and use that in a calculation.

I cannot get passed the errors.

double theRate;
double totalMileage;
double amountOwed;
private void btnCalculate_Click(object sender, EventArgs e)

[Code] ....

So how do you get numeric input from a user?

View 3 Replies


ADVERTISEMENT

C :: Function To Round A Number To Give Integer Number That Is Closer To Real Value

Oct 9, 2013

I was told to use a round function to round a number to give an integer number that is closer to the real value. (for example if the number is 114.67 I need to print an int value of 115 instead of 114)

I am not exactly sure how a round function works, but I am told to include math.h library. What I try doesn't seem to work.

View 1 Replies View Related

C :: How To Generate Real Number Between 0 And 1

Mar 1, 2015

I am a very very beginner at programming with C. Well, basically i have to generate a real number between 0 and 1 (which as the same as from 0 to 100 k and than dividing everything with 100 k).

Why I am constantly talking about 100 k? Because I would need approx 50 000 random numbers between 0 and 1. My code currently looks something like this:

Code:

int main(int argc, char** argv) { int min,max;
double number;
srand((unsigned)time(NULL));
number = 1 + rand()%100;
printf("The number is: %lf",number);
sleep(2);
return (EXIT_SUCCESS);
}

And If I am not mistaken, should generate numbers between 0 and 100. But I can't figure it out how to change to code in order to get enough numbers.

View 4 Replies View Related

C++ :: Program To Find Smallest Real Factor Of A Number

Oct 10, 2013

I need codes for a program in C or C++ that will show the real factor (the smallest one, without the number 1) when an integer is given as input.

When the program is started, it will ask to enter a number and press enter. After entering a number, it will first check if it is a prime number or not. If prime, it will notice that it is a prime number, otherwise, it will print the smallest real factor of the given integer.

For example, if 12 is entered, it will print, the smallest real factor for this number is: 2

If 27 is entered, it will print, the smallest real factor for this number is: 3

...and so on

View 12 Replies View Related

C :: Generate Pseudo Random Real Number From Interval (0,1)

Feb 6, 2013

How can I generate a pseudo-random real number from interval [0,1] ?

Can it be generalized to any interval? Like [0,a], where 'a' is a parameter?

I tried searching for it, I only found rand(), srand(), random(1), and randomize. None of it actually seems to work for me..

Later I actually succeeded with something like

srand( (unsigned)time( NULL ) );
printf( " %6d
", rand() );

but it only produces up to five digits integers and I cannot divide by 99999 to get it into [0,1].

View 11 Replies View Related

C++ :: How To Generate Real Random Number From Normal Distribution

Jun 26, 2013

I want to generate random numbers of normal distribution and use scentence like

std::default_random_engine generator;
std::normal_distribution<double> distribution(0,1);
arrayX[i][j]=distribution(generator);

But I find that each time the array I got are the same. So how should I generate random numbers with different seedings with normal distribution?

View 2 Replies View Related

C# :: Check Number Enter In Textbox And With DLL

Jul 12, 2014

This program with DLL that check number enter in textbox and use RGB for change color

example: if user enter 000 (000:black) changed color automatic textbox to black, and other 111 ....

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;

[Code]....

View 4 Replies View Related

C/C++ :: Check If Quartic Has Real Roots?

Feb 7, 2015

I have been writing code to find the roots of a quartic (with coefficients input by the user) by the Newton Rapson method. The method fails if no real roots exist so I have been trying to implement an initial check to see whether the equation has real roots. I've been trying to use the intermediate value theorem but it only works for functions with a positive and negative tail. extend the bounds (fa and fb) to check over many ranges or any other mathematical method of better effect?

Atm I define fa<0<fb where fa=F(-10) and fb=F(10).

#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
int a0, a1, a2, a3, a4;
double F(double x) //Sets main function {
return (a0+a1*x+a2*pow(x, 2)+a3*pow(x, 3)+a4*pow(x, 4));

[code].....

View 1 Replies View Related

C/C++ :: How To Take Data From Internet In Real Time

Apr 17, 2015

How i can take data from internet n real time i want make program wich alarm when a specific site(from my university) have a announcement...

View 6 Replies View Related

C/C++ :: Interactive And Animated Real-time Offline Map Application

Apr 25, 2015

I want to develop a interactive and animated real-time offline map application. For example if user puts mouse on the map, it should the latitude, longitude and name of the location.

There should be animation for example blinking of a location. And it should work offline without internet. I want to use google maps data but I don't know how.

I know following languages:
C/C++ (Advanced level)
PHP (intermediate level)
Java ( beginner level)

View 1 Replies View Related

Visual C++ :: Real Time Plotting Of Latitude And Longitude

Dec 17, 2012

Any application or open source software (vc++ or vb.net or c#.net) that can display a high resolution map and i can input real time latitude and longitude of points through an external file and those points can be displayed on map in real time..... I am all new to this plotting on map stuff....

View 2 Replies View Related

Visual C++ :: Implementing Real Time Graph To Application?

Nov 15, 2013

I was assigned a project to implement a real time graph to an application which continuously outputs data numerically through the GUI. The application that was created to do this is written in C.

I have to turn those numerical numbers into a graphical display that is periodically updated to appear as real time.

My adviser suggested using NTgraph [URL] ...... I had no clue how to implement this to my code and was finally able to understand that the .OCX needs to be registered as a COM and then imported to the application using visual studios. However, I get an error when I try importing it since it is in C (Visual Studios 8) and not an MFC application.

So my question is if it would be possible to implement the ActiveX control to my application even though it is not an MFC application and how to go about it.

View 6 Replies View Related

C++ :: Polynomial Coefficients Are Memorialized In Field Of Real Double Precision Numbers

Mar 19, 2013

I am starting to learn C++.Designing class CPolynom to work with polynomials. The polynomial coefficients are memorialized in the field of real double precision numbers. Implement the following functions:

-Constructor, which defines the order of the polynomial CPolynom(int order)
-method to add the appropriate grade Coef(int exp, duble coef)
-method of addition, subtraction, multiplication and division two polynomials
-method to add a field coefficient
-method for nala

View 1 Replies View Related

C# :: How To Use Textbox For Richtextbox

Nov 22, 2014

This is a simple dictionary program, richtextbox is used for a results

but i wants to use textbox as a richtext box

(ex:money = dollar,penny,rupees)
as a list : dollarpennyrupees

/> /> /> />

Project 2 Dic.txt = Project 2 Dic.rar

Attached File(s) : Project 2 Dic.txt (61.32K)

View 1 Replies View Related

C# :: Searching DB For Value In Textbox (WPF)

Nov 3, 2014

WPF window I'm working on. I have a window that has a textbox to enter a name to search a database table for, and when the search button is clicked, the ID for that username will be returned to a separate textbox. The code I've written atm doesn't seem to be working, but it looks fine to me. Here's what I've got;

private void btn_SearchUsers_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtb_SearchName.Text))
{
SqlConnection sqlCon = new SqlConnection(conStr);

[Code] .....

So, I have the value entered into the textbox to be searched for stored in a variable, I'm selecting the ID from the table when the name in the variable is found, storing the result in a DataTable, and then in my foreach loop, if I find the name (the name column being index 1 in the table), I set set the ID result textbox to equal the ID for that name (the ID column being index 0 in the table). I think the foreach part is what's throwing me off. Maybe the column stuff? My Users table is like;

ID Name
1 John
2 Roger
3 Mike

View 3 Replies View Related

C# :: How To Put Text Into Textbox

Jul 30, 2014

In my code below the first textbox.appendtext works but the second, textbox1.appendtext(i);, gives an error;

The name 'textbox1' does not exist in the current context (CS0103).

Is it possible to put text into the textbox from this routine?

namespace textboxtest {
public partial class MainForm : Form {
public MainForm() {
InitializeComponent();

[Code] ....

View 3 Replies View Related

C# :: Write WPF With Textbox

Mar 28, 2015

I was following a c# book to write a WPF with a textbox. When the textbox is selected(got focus) with keyboard or mouse, it will select all text in it. I followed the book and wrote this:

private void TextBox1_GotFocus(object sender, RoutedEventArgs e) {
TextBox1.SelectAll();
} private void TextBox1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
var control = sender as TextBox;

[Code] ....

The book said having "e.Handled = true" is to stop the event in order to prevent the cursor being positioned on somewhere of the text instead of selecting all text. From my understanding, "e.Handled = true" is for stopping routed events. Is this means that something will run if "e.Handled = true" is not there? If yes, then what is it?

View 2 Replies View Related

C# :: Class Not Getting Textbox Values

Sep 13, 2014

I am not able to get my textbox values in my Register class for my calcTotal method. However, if I convert the text to a double in the Form class and then pass that to my function it will work. But I don't understand why I need to do it like that.

namespace CashRegister {
class Register : Form1 {
public double getItemPrice(string str) {
double item = 0;
item = Convert.ToDouble(str);
return item;

[Code] .....

View 2 Replies View Related

C# :: Masked Textbox For Strings

Dec 20, 2014

How to use Masked Text Box if I want to use a string for mask? There is a question in the program and I want to be able to type in only the correct answer. So if the correct answer is Blue, and I start typeing It only accepts for the first caracter is B, then l and so on...

View 11 Replies View Related

C# :: Binding A String To A Textbox?

Aug 5, 2014

I have a textbox with XAML

<TextBox Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
Text="{Binding Path = EventDate, Mode=TwoWay}" />

And the Property

[edit]Note that auto formatting has edited onpropertychanged to all lowercase[/edit]
/// <summary>
/// Date that the event took place
/// </summary>
public string EventDate {

[code]....

In the constructor I have

EventDate = "Enter Date";

I have added a button

<Button Grid.Column="3" Content="Add Record" VerticalAlignment="Center" Click="AddRecordButtonclick"/>
public void AddRecordButtonclick(object sender, RoutedEventArgs e) {
Debug.WriteLine("Date value: " + EventDate);
}

What I am finding when I run this code is that when the Add Record button is clicked, the output displays, "Date value: Enter Date" regardless of what text I have in the textbox bound to EventDate.

Is there something obvious which I am missing with binding of a string to a textbox?

I've added this to the xaml, but the property is still not updating in the debug line

<TextBox Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
Text="{Binding Path=EventDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

View 7 Replies View Related

C/C++ :: How To Assign Text To A Textbox

Apr 24, 2015

I have a silverlight app that uses TextBox XAML controls.

In the c++ code-behind, IXRTextBoxPtr types are associated with these textboxes using "FindName" like this:

FindName(L"ColNum3", &m_pColNum3);

(where ColNum3 corresponds with the XAML CODE like this: )

Then, the code assigns the pointer like this:

std::wstring wsTransfer; // gets the wstring from imput
const WCHAR * wpszInput;
wpszInput = wsTransfer.c_str();
m_pColNum3->SetText(wpszInput);
but the display does not show the text data.

What am I missing? What steps am I missing to have this text modification display on the screen?

View 6 Replies View Related

C Sharp :: How To Add Textbox In Datatable In C#

Feb 13, 2013

how to add textbox in datatable in c#

View 3 Replies View Related

C Sharp :: How To Compare Value With Same Textbox In C#

Jan 26, 2015

I have a text format like this:

12-22-24-22-33-13

When user click a button then check for duplicated number in that text. How to handle this in C#.

View 1 Replies View Related

C/C++ :: Integer Division As Opposed To Real Division?

Sep 28, 2013

I have the following details
double x= 1.5
double y= -1.5
int m= 20
int n= 4

my question is 5 * x - n / 5 at which what would n / 5 equal to, I think its zero since its integer division? or would the 5 be considered a real number?

View 2 Replies View Related

C++ :: Using A Textbox And Other Items Between Multiple Forms

Oct 31, 2013

I am writing a program in Visual C++ 10 with 2 forms.

In the first form I have a textbox and a button. The button opens the second form.

In the second form, I have a button that changes the text in the textbox in form1 to an item from a listbox in form2.

Here is my problem. When I do the code for the button in form2 to change the textbox in form1 I get the errors:

error C2065: 'textBox1' : undeclared identifier
error C2227: left of '->Text' must point to class/struct/union/generic type

I thought maybe I should just include the "Form1.h" file but I can't do that because I already included "Form2.h" in form1 in order to be able to open the second form. If I try to include form1 in form2, it says that the code to open form2 is an error now.

My question is, how can I access identifiers such as "textbox1" from other forms and other files when I already used the first form to open the second form? I also want to know how to do this for all identifiers between all files.

how to print the selecteditem from a listbox into a textbox because that doesn't work by just setting them equal either.

Here is my code:

#pragma once
#include "Form2.h"
namespace Test1 {
using namespace System;

[Code].....

View 11 Replies View Related

C# :: How To Jump From One TextBox To Next When Press Enter Key

Apr 13, 2014

How can i jump from textBox to next texBox when i press enterKey in c# , what i the event for that .....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved