Autor Beitrag
validas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 35

WinXP, Win7
Microsoft Visual Studio 2010
BeitragVerfasst: Fr 09.09.11 11:05 
Hallo zusammen.

Folgendes Problem. Ich würde gerne eine TextBox auswerten, doch dies schlägt irgendwie fehl... =(

Codeschnippsel:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
        private void textBox4_Leave(object sender, EventArgs e)
        {
            if (textBox4.Text = " ")
            {
                textBox4.Text = "Bitte ausfüllen!";
            }
        }


Folgende ErrorMessage wird ausgegeben:

Error 1 Cannot implicitly convert type 'string' to 'bool' c:\daten\visual studio 2010\Projects\WinFormApp\WinFormApp\Form1.cs 57 17 WinFormApp

was ist hier schiefgelaufen???
Hilfe!!!

Danke schon im voraus!

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
Moderiert von user profile iconChristian S.: Topic aus Basistechnologien verschoben am Fr 09.09.2011 um 11:21
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Fr 09.09.11 11:09 
Hallo und willkommen im Forum :welcome:

Vergleiche machst du mit einem doppelten Gleichheitszeichen
ausblenden C#-Quelltext
1:
if (a == b) {...}					

Zuweisungen dagegen mit einem einfachen Gleichheitszeichen
ausblenden C#-Quelltext
1:
s = "Hallo Welt!";					

_________________
Delphi: XE - OS: Windows 7 Professional x64

Für diesen Beitrag haben gedankt: validas
validas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 35

WinXP, Win7
Microsoft Visual Studio 2010
BeitragVerfasst: Fr 09.09.11 11:22 
Ach so logisch! Tut mir leid, wirklich eine dumme Frage... :S

vielen Dank!
dark-destination1988
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 178
Erhaltene Danke: 21



BeitragVerfasst: Fr 09.09.11 11:49 
nur so als tipp:
wenn man testen will ob etwas eingegeben wurde,
nutze ich die string.IsNullOrEmpty("Hier steht ein string") Funktion.
Diese liefert true wenn der string leer ist.
storestore
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 397
Erhaltene Danke: 7

WIN 7
C#
BeitragVerfasst: Fr 09.09.11 15:29 
Hallo,
du darfst nicht:
ausblenden C#-Quelltext
1:
If(textBox4.text= "")					

sonder
ausblenden C#-Quelltext
1:
If(textbox4.text =="")					

machen.
Wenn du einen Vergleich machen willst dann immer mit == (zwei = hintereinander)
mfg storestore

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt

_________________
Der Pc ist nur so schlau, wie derjenige der in steuert!
"Don't Quit. Suffer now, and live the rest of your life as a champion"
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Fr 09.09.11 15:36 
@storestore
Du hast schon gesehen, dass exakt diese Antwort schon gegeben wurde, oder? :?

_________________
Delphi: XE - OS: Windows 7 Professional x64
dark-destination1988
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 178
Erhaltene Danke: 21



BeitragVerfasst: Fr 09.09.11 15:38 
naja schreibt er wenigstens mal was richtiges ;)
storestore
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 397
Erhaltene Danke: 7

WIN 7
C#
BeitragVerfasst: Sa 10.09.11 00:49 
Naja,
doppelt ist immer besser ;)
Zitat:
naja schreibt er wenigstens mal was richtiges ;)

Was soll das heißen? :twisted: :evil:

mfg storestore ;)

_________________
Der Pc ist nur so schlau, wie derjenige der in steuert!
"Don't Quit. Suffer now, and live the rest of your life as a champion"