Goodmorning Posted August 10, 2010 Report Share Posted August 10, 2010 Mam problem w Visual Basicu. Gdy próbuję dodać do siebie wartość z dwóch TextBoxów, pojawia mi się błąd: KODOperator '+' is not defined for types 'System.Windows.Forms.TextBox' and 'System.Windows.Forms.TextBox'.. W czym jest problem? Miejsce występowania błędu: KOD Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click MsgBox(Liczbaa+Liczbb) End Sub Link to comment Share on other sites More sharing options...
Adam27 Posted August 10, 2010 Report Share Posted August 10, 2010 A na pewno próbujesz dodać do siebie wartości textboxów? Bo z treści błędu można zrozumieć, że dodajesz same textboxy. Etharnion - 2D RPG Szukam grafika chętnego do współpracy przy projekcie. Link to comment Share on other sites More sharing options...
natanielcz Posted August 10, 2010 Report Share Posted August 10, 2010 może dodaj trzy zmienne. np. skladnik1, skladnik2, suma. pozniej daj skladnik1 = (nie wiem jak VB jest znak przypisania) i przypisz do pierwszego textboxa skladnik2 = to samo tylko zmien nazwe textboxa zależnie jak go nazwałes/as (tak a'propos ustaw płeć bo nie wiadomo jak się do cb zwracać) suma = skladnik1+skladnik2 MsgBox(suma) Link to comment Share on other sites More sharing options...
Goodmorning Posted August 10, 2010 Author Report Share Posted August 10, 2010 To jak mam dodać ich wartości? Postępuję według tego kursu i tam tak działa. EDIT @natanielcz: próbowałem, nie działa Link to comment Share on other sites More sharing options...
Adam27 Posted August 10, 2010 Report Share Posted August 10, 2010 Nie znam za bardzo VB, ale może spróbuj tak: KODMsgBox(Nazwa1.Text+Nazwa2.Text) Etharnion - 2D RPG Szukam grafika chętnego do współpracy przy projekcie. Link to comment Share on other sites More sharing options...
Goodmorning Posted August 10, 2010 Author Report Share Posted August 10, 2010 Nie znam za bardzo VB, ale może spróbuj tak: KOD MsgBox(Nazwa1.Text+Nazwa2.Text) Heh, wtedy kiedy piszę 2, a w drugim polu - 3, wyświetla się 23. Program ma dodawać liczby, czyli powinno się pokazać 5. Link to comment Share on other sites More sharing options...
Adam27 Posted August 10, 2010 Report Share Posted August 10, 2010 Zapoznaj się na googlach z zagadnieniem "konwersja typów". Etharnion - 2D RPG Szukam grafika chętnego do współpracy przy projekcie. Link to comment Share on other sites More sharing options...
natanielcz Posted August 10, 2010 Report Share Posted August 10, 2010 A może takie coś... MsgBox(Form1.TextBox1.Value+Form1.TextBox2.Value) i jednak poszukaj w googlach bo nikt tu w VB nie kodzi chyba Link to comment Share on other sites More sharing options...
Goodmorning Posted August 10, 2010 Author Report Share Posted August 10, 2010 Zapytałem na innym forum. Trzeba było użyć funkcji Val. Dziękuję za odpowiedzi. Link to comment Share on other sites More sharing options...
natanielcz Posted August 11, 2010 Report Share Posted August 11, 2010 moze napisz [roz] lub cos takiego na poczatku... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.