Advertisement
Yuven

Untitled

Dec 10th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.32 KB | None | 0 0
  1. Public Class Form1
  2.     Private Function beregnPris(ByVal romtype As String, ByVal antallgjester As Integer, ByVal antalldager As Integer)
  3.         Dim rompris As Integer
  4.         Dim frokost As Boolean
  5.         If chkFrokost.Checked Then
  6.             frokost = True
  7.         Else
  8.             frokost = False
  9.         End If
  10.         Select Case rompris
  11.             Case romtype = "enkeltrom"
  12.                 rompris = 645 * antalldager
  13.             Case romtype = "dobbeltrom"
  14.                 rompris = 995 * antalldager
  15.             Case romtype = "suite"
  16.                 rompris = 1295 * antalldager
  17.         End Select
  18.  
  19.         If antalldager > 5 Then
  20.             If romtype <> "suite" Then
  21.                 rompris = rompris * 0.8
  22.             End If
  23.         End If
  24.         If frokost = True Then
  25.             rompris += antallgjester * 55
  26.         End If
  27.         Return rompris
  28.     End Function
  29.     Private Sub antalldagerchanged(sender As Object, e As EventArgs) Handles txtAntallDager.TextChanged
  30.         If txtAntallDager.Text.Length > 0 Then
  31.             Try
  32.                 Convert.ToDouble(txtAntallDager.Text)
  33.             Catch ex As Exception
  34.                 MsgBox("Bruk nummer i antall dager!")
  35.                 txtAntallDager.Clear()
  36.             End Try
  37.         End If
  38.     End Sub
  39.  
  40.     Private Sub txtAntallGjester_TextChanged(sender As Object, e As EventArgs) Handles txtAntallGjester.TextChanged
  41.         If txtAntallGjester.Text.Length > 0 Then
  42.             Try
  43.                 Convert.ToDouble(txtAntallGjester.Text)
  44.             Catch ex As Exception
  45.                 MsgBox("Bruk nummer i antall gjester!")
  46.                 txtAntallGjester.Clear()
  47.             End Try
  48.         End If
  49.     End Sub
  50.  
  51.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  52.         Dim antallgjester = txtAntallGjester.Text
  53.         Dim antalldager = txtAntallDager.Text
  54.         Dim romtype = cboRomType.Text
  55.         Dim pris As Integer
  56.         If antallgjester > 0 And antalldager > 0 Then
  57.             pris = beregnPris(romtype, antallgjester, antalldager)
  58.             ListBox1.Items.Clear()
  59.             ListBox1.Items.Add("Navn: " & txtNavn.Text)
  60.             ListBox1.Items.Add("Epost: " & txtEpost.Text)
  61.             ListBox1.Items.Add("Totalpris:" & pris)
  62.         End If
  63.     End Sub
  64.  
  65.  
  66. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement