Value of type 'Single' cannot be converted to '1-dimensional array of Single'

edgedemon

Member
Joined
Nov 19, 2006
Messages
9
Programming Experience
Beginner
Guys, Im sorry if this is a bit simple, but Im so stuck and pretty frustrated right now :-(
Im trying to teach myself VB and Im in the process of writing a little test app as part of the learning process.
I have reached the stage where Im trying to create my first array, as I want to populate a list box with entries from a text field, so that I can then play around with subtracting/adding data together but I can not put any data into the array. I just get the error in the title. What is a 1 dimensional array?*!$ - Grrr
If I change "Dim rlbookings(9) As Integer" to "Dim rlbookings As Integer" then my list box transfers the integer from my sub total text field, but that is no good, I want it as an array so that I can play with the data - Can anyone tell me or point me in the right direction for where I am going wrong please?

Thanks



VB.NET:
[SIZE=2][COLOR=#0000ff]Option [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Strict [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Off[/COLOR][/SIZE]
 
 
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] TVU[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] rlbookings(9) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Single[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] nbookings [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] BtnCalc_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] BtnCalc.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] rlTxtRoom [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] rlTxtStay [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] rlTxtPrice [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] rlTxtCost [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] (IsNumeric(TxtPrice.Text) [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] TxtPrice.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2]) = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] (IsNumeric(TxtRoom.Text) [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] TxtRoom.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2]) = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] (IsNumeric(TxtStay.Text) [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] TxtStay.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2]) = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"You have entered An Invalid Charcter. Please input a Numeric Value"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]rlTxtRoom = [/SIZE][SIZE=2][COLOR=#0000ff]CSng[/COLOR][/SIZE][SIZE=2](TxtRoom.Text)[/SIZE]
[SIZE=2]rlTxtStay = [/SIZE][SIZE=2][COLOR=#0000ff]CSng[/COLOR][/SIZE][SIZE=2](TxtStay.Text)[/SIZE]
[SIZE=2]rlTxtPrice = [/SIZE][SIZE=2][COLOR=#0000ff]CSng[/COLOR][/SIZE][SIZE=2](TxtPrice.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]CSng[/COLOR][/SIZE][SIZE=2](TxtStay.Text) >= 5 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]rlTxtCost = (rlTxtPrice * 0.9) * (rlTxtRoom * rlTxtStay)[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2]rlTxtCost = (rlTxtRoom * rlTxtPrice) * TxtStay.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]TxtCost.Text = [/SIZE][SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][SIZE=2](rlTxtCost)[/SIZE]
[SIZE=2]TxtRoom.Text = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2]TxtStay.Text = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2]TxtPrice.Text = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] TxtStay_TextChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] TxtStay.TextChanged[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] TxtStay.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] IsNumeric(TxtStay.Text) = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"You have entered An Invalid Charcter. Please input a Numeric Value"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]CSng[/COLOR][/SIZE][SIZE=2](TxtStay.Text) >= 5 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Congratulations! - You receive a 5% Discount for Stays of 5 nights or more"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] LblPrice_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] LblPrice.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] LblCost_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] LblCost.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] TxtRoom_TextChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] TxtRoom.TextChanged[/SIZE]
[SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Label1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] LblInfo.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] TxtPrice_TextChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] TxtPrice.TextChanged[/SIZE]
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Label1_Click_1([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] TVU_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2]rlmemory = 0[/SIZE]
[SIZE=2]nBookings = 0 [/SIZE][SIZE=2][COLOR=#008000]' sets number of bookings to 0[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] TxtCost_TextChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] TxtCost.TextChanged[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] BtnAddBkng_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] BtnAddBkng.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] rlResult [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2]rlResult = [/SIZE][SIZE=2][COLOR=#0000ff]CSng[/COLOR][/SIZE][SIZE=2](TxtCost.Text)[/SIZE]
[SIZE=2]rlmemory = rlmemory + rlResult[/SIZE]
[SIZE=2]TxtSubtl.Text = [/SIZE][SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][SIZE=2](rlmemory)[/SIZE]
[SIZE=2]LstBkngs.Items.Add(TxtCost.Text)[/SIZE]
[SIZE=4]rlbookings = [COLOR=#0000ff]CSng[/COLOR](TxtCost.Text):mad: :mad: :mad: Generates error in title!!![/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] BtnBktl_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] BtnBktotal.Click[/SIZE]
[SIZE=2][COLOR=#008000]'TxtSubtl.Text = CStr(rlmemory)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs)[/SIZE]
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] BtnClr_GetFocus([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] BtnClr.Click[/SIZE]
[SIZE=2]TxtRoom.Clear()[/SIZE]
[SIZE=2]TxtStay.Clear()[/SIZE]
[SIZE=2]TxtPrice.Clear()[/SIZE]
[SIZE=2]TxtCost.Clear()[/SIZE]
[SIZE=2]TxtSubtl.Clear()[/SIZE]
[SIZE=2]LstBkngs.ClearSelected()[/SIZE]
 
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ListBox1_SelectedIndexChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs)[/SIZE]
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] TextBox1_TextChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] TxtSubtl.TextChanged[/SIZE]
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ListBox1_SelectedIndexChanged_1([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] LstBkngs.SelectedIndexChanged[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]
 
Last edited by a moderator:
Ok, seeing as you seem like someone who wants to figure this out by yourself i'm not going to write the code you should be using rather give you a pointer as to what an array is. When you do this....

VB.NET:
Dim rlbookings(9) AsSingle

You have dimesioned an array of the type single. So now rlbookings points to an array of 10 singles (10 because array's are zero based so 0 counts)

rlbookings(0) is a single
rlbookings(1) is a single
rlbookings(2) is a single.


And so on until you get to rlbookings(9). You get the error because you are using the varaible that points to the whole array in your code so visual basic doesn't know which member of the array you are trying to use.

With me or need a bit more of an explanation?
 
Thanks

Not completely with you, but I if I understand what you are saying I need an extra 'dim' statement for rlbookings...

It worked!

Dim rlResult As Double
Dim rlBooking As Single
rlResult = CSng(TxtCost.Text)
rlmemory = rlmemory + rlResult
TxtSubtl.Text =
CStr(rlmemory)
LstBkngs.Items.Add(TxtCost.Text)
rlbooking =
CSng(TxtCost.Text) - no squiggly line ;)

Then to start populating the array

rlbookings(nbookings) = rlBooking
nbookings = nbookings + 1

:) Ive only wasted 8 hrs googling and reading various pages full of code I didn't understand trying to relate back to what I was doing.
I stil do not get the '1 dimensional array' bit

To be honest, I sort of understand, but don't at the same time. But that is why I am practicing so that I can figure this all out. Ive obviously got a long way to go before I get to write my MP3/id3 tagger .

Thank you so much for your help, I think Id have been banging my head until eternity otherwise.

 
Don't get too bogged down with the terminology. Array sounds like it's a great big computerish term but is in actual fact very simple and the definition in programming terms means very much the same thing in real life. There really is no code to programming code.
A 1-dimensional array is exactly what it says it is.

Dim 1DimensionalArray(5) as Single

The above array has 6 slots for information..

1DimensionalArray(0)
1DimensionalArray(1)
..
..
..
1DimensionalArray(5)

Now a 2 dimensionalArray...

Dim 2DimensionalArray(5,5) as Single

2DimensionalArray(0,0)
2DimensionalArray(0,1)
2DimensionalArray(0,2)

0,3 all the way to 0,5 then the second dimension kicks in..

1,0
1,1
1,2

Get it.
 
Right, now I am really stuck

I guess that maybe I do not understand arrays properly, or I have set mine up wrong as I can not get it to work at all. I am trying to delete an entry from a list box, and then have the sub-total reflect that the value has been deleted from the list box. I searched around on the web, and modified an example I saw to suit my purposes, or so I thought. I get no compile errors, but it just does not work, and I don't understand it enough to properly analyse it. All the examples I saw were far to complicated, and I was guessing a bit, but if someone could explain to me where I am going wrong it would be appreciated to say the least...

Option Strict Off


Public
Class TVU
Dim rlbookings(9) As Single ' creates array
Dim nbookings As Single ' creates array index
Private Sub BtnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalc.Click
Dim rlTxtRoom As Integer
Dim rlTxtStay As Integer
Dim rlTxtPrice As Double
Dim rlTxtCost As Double
If (IsNumeric(TxtPrice.Text) And TxtPrice.Text <> "") = False _
Or (IsNumeric(TxtRoom.Text) And TxtRoom.Text <> "") = False _
Or (IsNumeric(TxtStay.Text) And TxtStay.Text <> "") = False Then
MsgBox("You have entered An Invalid Charcter. Please input a Numeric Value")
Exit Sub ' stops non-numeric data entry
End If
rlTxtRoom = CSng(TxtRoom.Text)
rlTxtStay =
CSng(TxtStay.Text)
rlTxtPrice =
CSng(TxtPrice.Text)
If CSng(TxtStay.Text) >= 5 Then
rlTxtCost = (rlTxtPrice * 0.9) * (rlTxtRoom * rlTxtStay)
Else
rlTxtCost = (rlTxtRoom * rlTxtPrice) * TxtStay.Text
End If
TxtCost.Text = CStr(rlTxtCost)
TxtRoom.Text =
""
TxtStay.Text = ""
TxtPrice.Text = ""

End Sub
Private Sub TxtStay_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtStay.TextChanged
If TxtStay.Text <> "" Then
If IsNumeric(TxtStay.Text) = False Then
MsgBox("You have entered An Invalid Charcter. Please input a Numeric Value")
Else
If CSng(TxtStay.Text) >= 5 Then
MsgBox("Congratulations! - You receive a 5% Discount for Stays of 5 nights or more")
End If
End If
End If
End Sub
Private Sub LblPrice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LblPrice.Click
End Sub
Private Sub LblCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LblCost.Click
End Sub
Private Sub TxtRoom_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtRoom.TextChanged
Exit Sub
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LblInfo.Click
End Sub
Private Sub TxtPrice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtPrice.TextChanged

End Sub
Private Sub Label1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TVU_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
rlmemory = 0
'ensures rlmemory variable is set to 0
nBookings = 0 ' sets number of bookings to 0
End Sub
Private Sub TxtCost_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtCost.TextChanged
End Sub
Private Sub BtnAddBkng_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAddBkng.Click
Dim rlResult As Double
Dim rlBooking As Single
rlResult = CSng(TxtCost.Text)
rlmemory = rlmemory + rlResult
TxtSubtl.Text =
CStr(rlmemory)
LstBkngs.Items.Add(TxtCost.Text)
rlbooking =
CSng(TxtCost.Text)
rlbookings(nbookings) = rlBooking
nbookings = nbookings + 1
TxtCost.Clear()


End Sub
Private Sub BtnBktl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBktotal.Click
If IsNumeric(TxtCost.Text) = False Then
TxtCost.Text = CStr(rlmemory)
Else
TxtCost.Text = CStr(rlmemory) + CSng(TxtCost.Text)
End If
'Stops an empty subtotal field crashing the program
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub
Private Sub BtnClr_GetFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClr.Click
TxtRoom.Clear()
TxtStay.Clear()
TxtPrice.Clear()
'Clears all the text fields
TxtCost.Clear()
TxtSubtl.Clear()





End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtSubtl.TextChanged

End Sub

Private Sub ListBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstBkngs.SelectedIndexChanged
End Sub
Private Sub BtnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDel.Click
Dim i As Single
Dim nbookings As Single
Dim index As Integer
For index = 0 To nbookings - 1
rlbookings(index) = 0
Next index

nbookings =
CSng(LstBkngs.SelectedItem)
For i = nbookings To nbookings - 1
rlbookings(i) = rlbookings(i + 1)
rlbookings(i) = rlbookings(i + 1)
Next i
nbookings = nbookings - 1
LstBkngs.Items.RemoveAt(LstBkngs.SelectedIndex)
' removes selected listbox item
End Sub
End
Class
 
A fresh start..

Looking at at with slighly less tired brain cells, I think I need to look at adding the necessary maths to the end, I was thinking that I could just do everything from the array, but reading around a bit, Im not so sure now. And Im still not sure some of my variables are right. Oh well, at least I have something to look at raather then raw frustration
 
I've had a look at that code you posted, and it was most likely written for .Net 2003. Also i dunno who wrote it but there are some fundamental floors in it with regards to validation and such. I've gotta be honest, it's not a good starting point for you. What exactly is the database application you are trying to create here about? Or is this just somewhere you thought would be a good starting point, if it's the latter then stop there and find something familiar for you to base your application on.
 
edge: Just a note.. When you post code, first turn off advanced text input using this button
switchmode.gif
in the TOP RIGHT corner of the posting box (click it and wait maybe 5 seconds for the textbox background to change from pale blue-> white)

then click the
code.gif
CODE button and the CODE tags will appear. the cursor is auto positioned in the middle of them
press ctrl V to paste your code

that way your code appears like this:

VB.NET:
hello world!
  this
    is
      indented!

The purpose of pressing the
switchmode.gif
button is to prevent the syntax highlighting from showing up. It looks very nice, but it also gets screwed up, because all the blue words appear stuck together - its not how they are in the source code and it makes it hard for us to paste it into our VB and run it to check..
 
Back
Top