---
title: "Lite If sats problem"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/136808-lite-if-sats-problem"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Asa"
published: "2005-11-01T20:31:01.000Z"
updated: "2005-11-01T20:44:34.000Z"
replies: 4
views: 257
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/asp/136808-lite-if-sats-problem"
---

# Lite If sats problem

## #1 — Asa, 2005-11-01T20:31Z

Har följande ifsats som inte vill skriva ut rätt. Formatet på totvikt är ex 2,4 (float(14,2)) 

```
    
    strVikt = Replace(totVikt,",",".")

    If strVikt <= 1 Then
      strViktKR = "86"
    ElseIf strVikt > 1 and strVikt <= 5 Then
      strViktKR = "108"
    ElseIf strVikt > 5 and strVikt <= 10 Then
      strViktKR = "140"
    ElseIf strVikt > 10 and strVikt <= 15 Then
      strViktKR = "169"
    ElseIf strVikt > 15 and strVikt <= 20 Then
      strViktKR = "209"
    ElseIf strVikt > 20 and strVikt <= 30 Then
      strViktKR = "226"
    ElseIf strVikt > 30 and strVikt <= 40 Then
      strViktKR = "254"
    ElseIf strVikt > 40 and strVikt <= 60 Then
      strViktKR = "300"
    End If
```

 

Vad gör jag för fel?

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

## #2 — emission, 2005-11-01T20:33Z

Du jämför äpple och päron, eller mer specifikt: strängar och tal.

```
strVikt = Replace(totVikt,",",".")
dblVikt=cdbl(strVikt)
    If dblVikt <= 1 Then
      strViktKR = "86"
    ElseIf dblVikt > 1 and dblVikt <= 5 Then
      strViktKR = "108"
    ElseIf dblVikt > 5 and dblVikt <= 10 Then
      strViktKR = "140"
    ElseIf dblVikt > 10 and dblVikt <= 15 Then
      strViktKR = "169"
    ElseIf dblVikt > 15 and dblVikt <= 20 Then
      strViktKR = "209"
    ElseIf dblVikt > 20 and dblVikt <= 30 Then
      strViktKR = "226"
    ElseIf dblVikt > 30 and dblVikt <= 40 Then
      strViktKR = "254"
    ElseIf dblVikt > 40 and dblVikt <= 60 Then
      strViktKR = "300"
    End If
```

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

## #3 — Asa, 2005-11-01T20:37Z

Detta verkar ej fungera:

```
<%
totVikt = "5,3"

strVikt = Replace(totVikt,",",".")
dblVikt=cdbl(strVikt)
    If dblVikt <= 1 Then
      strViktKR = "86"
    ElseIf dblVikt > 1 and dblVikt <= 5 Then
      strViktKR = "108"
    ElseIf dblVikt > 5 and dblVikt <= 10 Then
      strViktKR = "140"
    ElseIf dblVikt > 10 and dblVikt <= 15 Then
      strViktKR = "169"
    ElseIf dblVikt > 15 and dblVikt <= 20 Then
      strViktKR = "209"
    ElseIf dblVikt > 20 and dblVikt <= 30 Then
      strViktKR = "226"
    ElseIf dblVikt > 30 and dblVikt <= 40 Then
      strViktKR = "254"
    ElseIf dblVikt > 40 and dblVikt <= 60 Then
      strViktKR = "300"
    End If

Response.Write "Vikt: " & totVikt & "<br>"
Response.Write "Frakt: " & strViktKR
%>
```

Den skriver ut 300 kr

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

## #4 — @nders, 2005-11-01T20:39Z

Då är det väl kommatecken som gäller som decimaltecken i din installation.

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

## #5 — Asa, 2005-11-01T20:44Z

Då skall jag testa med det!

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/136808-lite-if-sats-problem
