hi im new to vb and i have just run into a mind boggleing prob i think i have tried just about everything to get this working but it just wont work

my question is when calling a function in my case Charge(nights)
i get a litte := after nights can anyone tell my why this is ??

Recommended Answers

All 8 Replies

It will help you if you post your code...

Function Charge(ByVal Nights As Integer) As Single
Dim NightsStayed As Integer
Dim cost As Single

If (NightsStayed <= 7) Then
Cost = NightsStayed * 155.0
Else

If (NightsStayed <= 14) Then
Cost = (7 * 155) + (NightsStayed - 7) * 133.0
Else
Cost = (7 * 155.0) + (7 * 133.0) + (NightsStayed - 14) * 120.0
End If
End If


End Function

I changed your code to

Function Charge(ByVal Nights As Integer) As Single
  'Dim NightsStayed As Integer
  Dim cost As Single

  If (Nights <= 7) Then
    cost = CSng(Nights * 155.0)
  Else

    If (Nights <= 14) Then
      cost = CSng((7 * 155) + (Nights - 7) * 133.0)
    Else
      cost = CSng((7 * 155.0) + (7 * 133.0) + (Nights - 14) * 120.0)
    End If
  End If

  Return cost

End Function

That's how it should be, right?

I tested it with TextBox1.Text = Charge(8).ToString("0.00") and the result was 1218.00 which is correct.

Now, where/how do you exactly get that ":=" ? Do you get it in VB.NET IDE i.e. editor while you write code or at the run time?

i have no idea where it came from but whenever i call the function it wants to stick the := in and i didnt type it anywere but ill give your rewrite ago see if that fixes my prob

lol look its got me stumped where the funny little := came from or how i was getting it .... mabee it was in the way i was calling it or something?

this is what i got after the rewrite b4 it i just had the one

I don't see any problem neither in the way you call the function nor in the way you have declared the function parameter.

Only thing that came in to my mind was that you had declared "Nights" twice. That's possible by declaring it in two modules, but if you try to use "Nights" in a third module or in a form, you'll get an error stating that "Nights" is ambiguous. I also tried to switch Option Strict and Option Explicit settings Off but that had no effect. Finally, whatever I tried to do, I wasn't able to re-produce "Nights:=". I used VB.NET 2005. Not sure if there's something in the VB.NET 2008 what could do that. The only 'advice' I can give, is to search for the occurrences (declarations to be precise) of the "Nights" string. If you find it declared twice in your project, try to change other declaration to something else.

Anyway, never seen something like that and I wasn't able to re-produce it. Beats me up :D

lol makes two of us ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.