ショッピング カート フォームのDim MyCollection As New AudioBooks
ステートメントを使用して、メモリ内の場所をインスタンス化しました。Public Class ShoppingCart
ここで、オーディオブックの変数をフォームで宣言Dim StrLearnCalclusInOneDayAB As String
しました。Public Class AudioBooks
If ListBox1.Items.Contains(Me.MyCollection.StrLearnCalclusInOneDayAB)
これが私の主な構文エラーです。listbox1 を調べて、オーディオブックの変数があるかどうかを確認する必要があります。私はこれを間違って認定していますが、イライラするほど単純であることを知っています。
これが完全なコードです。私は VB チューターが必要で、質問ごとに 5 ドルを支払います。以下はコードの全文です。
Public Class ShoppingCart
Dim Tax As Decimal
Dim PB1 As Decimal
Dim AB1 As Decimal
Dim MyCollection As New AudioBooks
'My overall objective is to move the strings from audiobooks and printbooks to shopping cart and calculate the total
'I was instructed to use a module
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
Tax = 0.06
End Sub
Private Sub PrintBooksToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintBooksToolStripMenuItem.Click
'Create an instance of the printbook
Dim frmPrintBook As New PrintBook
'Display the form in modal styple
frmPrintBook.ShowDialog()
End Sub
Private Sub AudioBooksToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AudioBooksToolStripMenuItem.Click
'Create an instance of the audiobook
Dim frmAudioBook As New AudioBooks
'Display the form in modal style
frmAudioBook.ShowDialog()
End Sub
Public Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
'Dim MyCollection As New AudioBooks
'I want to run an if else statement which checks Listbox1 to see what books are in the cart and calculates the total
'I'm having trouble finding these variables(from audiobooks) with intelligsense, 'StrLearnCalclusInOneDayAB' etc.
'I'm pretty sure I need a new instance of memory from the audio bookcooks class to use the object variables
'declared in that class. I'm having trouble getting the syntax right. Intelligsense only will find the lstboxaudio
'The book says, form's class-level variables are accessible to statements in the form file,
'they are not accessible by default to statements outside the form file
'I want the code to look like this, only lstboxAudio comes up in Intelligsense, why is this, I want StrLearnCalclusInOneDayAB to
'Also I'm not sure I'm using contains correctly, hope I was clear
'I will eventually need to total the books in the cart, why Can't intellisense find the variable?
'This is my primary question
If ListBox1.Items.Contains(MyCollection.StrLearnCalclusInOneDayAB) Then
End If
Cart.IDidItYourWay = 11.95
Cart.TheHistoryofScotland = 14.5
Cart.LearnCalculusInOneDay = 29.95
Cart.FeelTheStress = 18.5
Cart.LearnCalculusInOneDayAB = 29.95
Cart.RelaxationTechniques = 11.5
Cart.TheScienceOfBodyLanguage = 12.95
Cart.TheHistoryOfScotlandAB = 14.5
'I feel I shouldn't have to reference an object to change properties in a class, why must I do that?
'This question might not make sense.
End Sub
Private Sub lblSubtotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblSubtotal.Click
End Sub
クラス終了
Public Class AudioBooks
Public Sub lstboxAudio_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxAudio.SelectedIndexChanged
End Sub
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim AudioBooks1 As String
'AudioBooks1 = lstboxAudio.SelectedItem.ToString
'Save the selected item to a string
'ShoppingCart.ListBox1.Items.Add(AudioBooks1)
'shopping cart form, listbox1, items, add, that string of audiobooks
Dim StrLearnCalclusInOneDayAB As String
StrLearnCalclusInOneDayAB = lstboxAudio.Items(0).ToString
'If strLearnCalculusInOneDayAB is selected then add to the shopping cart listbox
If lstboxAudio.SelectedIndex = 0 Then
ShoppingCart.ListBox1.Items.Add(StrLearnCalclusInOneDayAB)
End If
' if the selectedindex of lslboxaudio is 0, the string is selected
'then move it to the shoppingcart
Dim StrTheHistoryOfScotlandAB As String
StrTheHistoryOfScotlandAB = lstboxAudio.Items(1).ToString
If lstboxAudio.SelectedIndex = 1 Then
ShoppingCart.ListBox1.Items.Add(StrTheHistoryOfScotlandAB)
End If
Dim StrTheScienceOfBodyLangAB As String
StrTheScienceOfBodyLangAB = lstboxAudio.Items(2).ToString
If lstboxAudio.SelectedIndex = 2 Then
ShoppingCart.ListBox1.Items.Add(StrTheScienceOfBodyLangAB)
End If
Dim StrRelaxationTechniquesAB As String
StrRelaxationTechniquesAB = lstboxAudio.Items(3).ToString
If lstboxAudio.SelectedIndex = 3 Then
ShoppingCart.ListBox1.Items.Add(StrRelaxationTechniquesAB)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
クラス終了