What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Probelem with int to string convert

  • Thread starter Thread starter weischbier
  • Start date Start date
W

weischbier

Guest
Hi,

i'm designing at the moment my GUi for my CC and i got some problems.
I want the user to set up several Settings via a Number in a Textbox.
Now that Number should be saved and should be handeled with in the CC.

Lets say: 85 is the value i want Anti-Magic shell to be casted.

i say:
Code:
amsvalue_.Text = Deathknight.Instance.Settings.amsvalue;
But all what is behind the = got a red underline.

I declared it as an int.
Code:
[Setting, DefaultValue(85)]
public int amsvalue { get; set; }

in the CC it looks like this:
Code:
                if (Me.HealthPercent < Deathknight.Instance.Settings.amsvalue)
                {
                    CastSpell(ams);
                }

i don't know how to handle that.

Maybe anybody of you can =)


Greetz

Weischbier
 
Last edited by a moderator:
Assuming amsvalue_ is a TextBox, and Deathknight.Instance.Settings.amsvalue is an integer, your conversions would look like the following:

PHP:
// Convert integer to string
amsvalue_.Text = Deathknight.Instance.Settings.amsvalue.ToString();


// Going back the other way (string to int) is not so easy...
// you have to 'parse' the value to convert it back to integer.
if (!int.TryParse(amsvalue_.Text, out Deathknight.Instance.Settings.amsvalue))
{
    Logging.Write("Malformed value encountered for amsvalue (saw '" + amsvalue_.Text + "')");
    return false;
}

You would probably be better off making amsvalue_ a NumericUpDown instead of a TextBox. As, NumericUpDown will return the value to you in native integer form (i.e., its Value property is an integer), instead of the string returned by TextBox.


cheers,
chinajade
 
Last edited:
Hi,

now he's bugging me with another error:
Code:
        private void reset()
        {
            amsvalue_.Value = Deathknight.Instance.Settings.amsvalue;
            ifvalue_.Value = Deathknight.Instance.Settings.ifvalue;
            dsvalue_.Value = Deathknight.Instance.Settings.dsvalue;
            fsvalue_.Value = Deathknight.Instance.Settings.fsvalue;
        }
This works now!

This not:
Code:
        public void DBEGUI_FormClosing(object sender, FormClosedEventArgs e)
        {
            Deathknight.Instance.Settings.amsvalue = amsvalue_.Value ;
            Deathknight.Instance.Settings.ifvalue = ifvalue_.Value;
            Deathknight.Instance.Settings.dsvalue = dsvalue_.Value;
            Deathknight.Instance.Settings.fsvalue = fsvalue_.Value;
            Deathknight.Instance.Settings.Save();
        }

This is the error message: (i'm using the german client)
Code:
Fehler	1	Der Typ "decimal" kann nicht implizit in "int" konvertiert werden. Es ist bereits eine explizite Konvertierung vorhanden. (M?glicherweise fehlt eine Umwandlung.)	C:\Users\Danny\Documents\Visual Studio 2010\Projects\CC + GUI + Config\Deathknight - Barebone GUI Edition\GUI.cs	82	54	Deathknight - Barebone GUI Edition
He says that there is possibly a missing conversion from decimal to int. Its not red underlined but blue.

Greetz

Weischbier
 
weischbier said:
He says that there is possibly a missing conversion from decimal to int. Its not red underlined but blue.

It should be...
PHP:
public void DBEGUI_FormClosing(object sender, FormClosedEventArgs e)
{
   Deathknight.Instance.Settings.amsvalue = (int)amsvalue_.Value ;
   Deathknight.Instance.Settings.ifvalue = (int)ifvalue_.Value;
   Deathknight.Instance.Settings.dsvalue = (int)dsvalue_.Value;
   Deathknight.Instance.Settings.fsvalue = (int)fsvalue_.Value;
   Deathknight.Instance.Settings.Save();
}

These are very basic C# considerations. I'd recommend Google--its your friend when trying to learn a new programming language. If you like hardcopy, the two books I'd recommend for C# are...


cheers,
chinajade
 
These are very basic C# considerations. I'd recommend Google--its your friend when trying to learn a new programming language. If you like hardcopy, the two books I'd recommend for C# are...


cheers,
chinajade

Yeah, I'll definatley go into this.

Thanks for your help. There are no more code errors (nothing c# shows me).
HB is compiling it and accepts it but i can't call the GUI.
It gets me this error:
Code:
System.Resources.MissingManifestResourceException: F?r die angegebene Kultur oder die neutrale Kultur konnten keine Ressourcen gefunden werden. Stellen Sie sicher, dass Barebone.DBEGUI.resources beim Kompilieren richtig in die Assembly Default Deathknight_634381978606821989 eingebettet wurde, oder dass die erforderlichen Satellitenassemblys geladen werden k?nnen und vollst?ndig signiert sind.
   bei System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   bei System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   bei System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   bei System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   bei System.Resources.ResourceManager.GetString(String name)
   bei Barebone.DBEGUI.InitializeComponent() in c:\Users\Danny\Desktop\HB\NoMovementHB\CustomClasses\Default Deathknight\GUI.Designer.cs:Zeile 607.
   bei Barebone.DBEGUI..ctor() in c:\Users\Danny\Desktop\HB\NoMovementHB\CustomClasses\Default Deathknight\GUI.cs:Zeile 17.
   bei Barebone.Deathknight.OnButtonPress() in c:\Users\Danny\Desktop\HB\NoMovementHB\CustomClasses\Default Deathknight\Frost CC.cs:Zeile 58.
   bei ..†(Object sender, EventArgs e)
   bei System.Windows.Forms.Control.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
   bei System.Windows.Forms.Button.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I read through this but only get the first sentence. He's missing any Ressources.

This is how i call it:
Code:
        public override bool WantButton
        {
            get
            {

                return true;
            }
        }

        public override void OnButtonPress()
        {
            DBEGUI form = new DBEGUI();
            form.Show();
        }

Greetz Weischbier
 
it's hard to find an error without the source :)
r u using the resourcemanager? and if yes, is it really needed?
 
Your right.

i'll attach the whole project so its easier to see what will do what etc.

it's just that last thing. if that will gonna work i'm can do the CC and figure out the how to use and such things.

Appreciate your help!

Greetz

Weischbier
 
do u copied the GUI.resx file to the cc-directory? or only all ur .cs Files?

havent tried it yet (sitting at work), but it seems missing the GUI.resx file
 
Yes, i have.

Code:
Could not find a routine fitting for your class. Please make sure you have a proper combat class routine in your folder, and restart Honorbuddy.
Current CC does not have any configuration

This is how it ended up^^

Greetz

Weischbier
 
Back
Top