---
title: "Summa av label"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/180022-summa-av-label"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "liverpool"
published: "2009-08-30T08:34:44.000Z"
updated: "2009-08-30T22:03:27.000Z"
replies: 6
views: 562
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/180022-summa-av-label"
---

# Summa av label

## #1 — liverpool, 2009-08-30T08:34Z

Hej

Jag vill summera min värden i labels? Någon som vet

```

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = TextBox1.Text * ("5,5").ToString
        Label2.Text = TextBox2.Text * ("0,75").ToString
        Label3.Text = TextBox3.Text * ("1,4").ToString
        Label4.Text = TextBox4.Text * ("0,4").ToString
        Label5.Text = Här vill jag summera Label 1+2+3+4
    End Sub
```

Permalänk: https://www.webforum.nu/p/180022

## #2 — FreeZer, 2009-08-30T10:38Z

Label1.Text = (float.Parse(TextBox1.Text) \* 5,5).ToString();
osv

Label5.Text = (float.Parse(Label1.Text) + ... + float.Parse(Label4.Text)).ToString();

Lite hjälp på vägen iaf.

Permalänk: https://www.webforum.nu/p/2200388

## #3 — liverpool, 2009-08-30T11:03Z

Är detta skrivet i C#. Jag använder VB. Får upp ett felmeddelande där det står:
float is not declare?

Permalänk: https://www.webforum.nu/p/2200391

## #4 — liverpool, 2009-08-30T11:26Z

Hej

Kanske världens bästa kod men det fungerar. Men summa blir i heltal. Jag vill ha med 2 decimaler. Någon som vet ?

```
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = TextBox1.Text * ("5,5").ToString
        Label2.Text = TextBox2.Text * ("0,75").ToString
        Label3.Text = TextBox3.Text * ("1,4").ToString
        Label4.Text = TextBox4.Text * ("0,4").ToString
        Label5.Text = TextBox5.Text * ("1").ToString
        
        Dim intTotal As Integer
        Dim int1 As Integer
        Dim int2 As Integer
        Dim int3 As Integer
        Dim int4 As Integer
        Dim int5 As Integer
        
        ' Get the values from the input boxes.
        int1 = CInt(Label1.Text)
        int2 = CInt(Label2.Text)
        int3 = CInt(Label3.Text)
        int4 = CInt(Label4.Text)
        int5 = CInt(Label5.Text)
        ' Get the total and display it.
        intTotal = int1 + int2 + int3 + int4 + int5
        Label13.Text = CStr(intTotal) **** Här vill jag ändra svaret till 2 decimaler!!
        
        
    End Sub
```

Permalänk: https://www.webforum.nu/p/2200393

## #5 — cok, 2009-08-30T16:23Z

Integer är heltal, testa decimal, float eller double

Permalänk: https://www.webforum.nu/p/2200400

## #6 — liverpool, 2009-08-30T16:58Z

Nope. Samma problem

Permalänk: https://www.webforum.nu/p/2200401

## #7 — liverpool, 2009-08-30T22:03Z

Löste det med Dim int1 As Decimal och med CDec istället för CInt

Permalänk: https://www.webforum.nu/p/2200415

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/180022-summa-av-label
