int to string help
6 posts
Page 1 of 1
ok so i have this
how can i use switch with a string, not a number
btw im betting at least 6 bucks that mandai, zulf, or mike will answer the best
Code: Select all
and you see where it says "String op" i dont want the variable op to be a String i want it to be a int or if i cantString fn = JOptionPane.showInputDialog("Enter your first number");
String sn = JOptionPane.showInputDialog("Enter your second number");
String op = JOptionPane.showInputDialog("Enter either divide(1), multiply(2), subtract(3), add(4)");
if (op<1){
JOptionPane.showMessageDialog(null, "Not Applicable, must use numeral character or number may not be smaller than 1", "ERROR", JOptionPane.ERROR_MESSAGE);
}
if (op>4){
JOptionPane.showMessageDialog(null, "Not Applicable, must use numeral character or number may not be larger than 4", "ERROR", JOptionPane.ERROR_MESSAGE);
}
switch (op){
case 1:
}
how can i use switch with a string, not a number
btw im betting at least 6 bucks that mandai, zulf, or mike will answer the best
You should use this (C#):
Code: Select all
Is there a particular reason why this is in the JavaScript section? If this was JavaScript you would not need to worry about parsing as there are no strict rules on data types.int number = int.Parse(op);
Last edited by mandai on Thu Aug 04, 2011 1:44 pm, edited 1 time in total.
Use
to convert from an int to a string
or
Hope this helps
Edit: Oh wait, are you doing this in VB.NET?
Code: Select all
convert.tostring(whatever your int is)
to convert from an int to a string
or
Code: Select all
to convert from string to an int.convert.toint32(your string here)
Hope this helps
Edit: Oh wait, are you doing this in VB.NET?
no this is java_script and mandai i swear this is truly java-script but the program i use to program is eclipse but it keeps saying that its wrong and i cant
Bogoh67 wrote:no this is java_script and mandai i swear this is truly java-script but the program i use to program is eclipse but it keeps saying that its wrong and i cantDude Javascript, and Java are two completely different programming languages. Maybe you should take a look at this topic I posted on the Evolution of Computer Programming Languages.
Now by looking at your code it's Java, not Javascript, and that means this post belongs here.
Also I see your code is similar to one of the first Java tutorials I watched by Bucky (thenewboston) when you ever get into gui development. Here's something to get you started. (It's just a window, but once you get better you can add a file menu, images, etc:)
Code: Select all
import javax.swing.JFrame;
public class app {
public static void main(String [] args) {
new tapp();
}
private static class tapp extends JFrame {
public tapp() {
super();
setTitle("TestApp");
setSize(320,240);
setLocationByPlatform(true);
setAlwaysOnTop(false);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
}
excuse me for my newbieness then , and thanks for sharing the code!!!!
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023