WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Programmierung

Programmierung Rat & Tat für Programmierer

Microsoft KARRIERECAMPUS

Antwort
 
Themen-Optionen Ansicht
Alt 14.11.2003, 17:22   #1
Potassium
Inventar
 
Registriert seit: 06.03.2003
Alter: 37
Beiträge: 3.954

Mein Computer

Ausrufezeichen inhalt von variable prüfen (vb)

hi leute
ich möchte feststellen ob in einer variable ein bestimmter string enhalten ist. zb: variable1 = "hallo das ist ein test"
if variable2 enthält "das" then
.....
endif
wie mach ich das?
Potassium ist offline   Mit Zitat antworten
Alt 14.11.2003, 17:36   #2
jak
Inventar
 
Registriert seit: 13.06.2001
Beiträge: 1.830


Standard

In den meisten Sprachen gibt es indexOf. Dann würde es mit
Dim a as String;
a="test das ist";
if(a.indexOf("das")!=-1)...

gehen. Ob es den Befehl in Vb wirklich gibt weis ich aber nicht.

Jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
jak ist offline   Mit Zitat antworten
Alt 14.11.2003, 17:45   #3
Potassium
Inventar
 
Registriert seit: 06.03.2003
Alter: 37
Beiträge: 3.954

Mein Computer

Standard

funzt zumindeste so ned in vb?
any other ideas?
Potassium ist offline   Mit Zitat antworten
Alt 14.11.2003, 17:50   #4
flinx
Inventar
 
Registriert seit: 08.04.2001
Beiträge: 3.101


Standard

StrComp ?
flinx ist offline   Mit Zitat antworten
Alt 14.11.2003, 17:54   #5
jak
Inventar
 
Registriert seit: 13.06.2001
Beiträge: 1.830


Standard

Vielleicht mit InStr ?

In Vb.net müsste IndexOf gehen.
Zitat:
This code starts at the beginning of 'The weather today is reasonably warm and sunny', because we didn't give a start position, and searches for the word 'warm' in it. If it does not find the word warm in the string, then it will return the value as 0, and you get a message saying '0'. However, if it finds the word, then it returns a number saying where it found the start of the word. In this case, you would see a messagebox saying '32' because the 'w' of warm is 32 characters into the string.

Dim r As String = "The weather today is reasonably warm and sunny"
r = r.IndexOf("warm")

MsgBox(r)
Quelle: http://pscode.com/vb/scripts/ShowCod...=169&lngWId=10

Jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
jak ist offline   Mit Zitat antworten
Alt 14.11.2003, 18:35   #6
moorhahn
Veteran
 
Registriert seit: 26.12.2000
Beiträge: 489


moorhahn eine Nachricht über ICQ schicken
Standard

http://msdn.microsoft.com/library/de...vafctinstr.asp
in der msdn-library gucken

edit: eigentlich ein wunder das _m3 nicht mit der msdn-library schon zuvorgekommen is
____________________________________
Wenn Null ganz besonders gross ist, ist es schon fast so viel wie ein kleines bisschen Eins... - (Kommentar zum Thema Rundungsfehler bei Fliesskommazahlen).
moorhahn ist offline   Mit Zitat antworten
Alt 14.11.2003, 18:52   #7
jak
Inventar
 
Registriert seit: 13.06.2001
Beiträge: 1.830


Standard

Wenn man nicht weiß wie die Funktion heißt kann amn aber lang suchen

Jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
jak ist offline   Mit Zitat antworten
Alt 14.11.2003, 21:03   #8
moorhahn
Veteran
 
Registriert seit: 26.12.2000
Beiträge: 489


moorhahn eine Nachricht über ICQ schicken
Standard

kann man ja zb nach "string" suchen, und verweise durchstöbern
____________________________________
Wenn Null ganz besonders gross ist, ist es schon fast so viel wie ein kleines bisschen Eins... - (Kommentar zum Thema Rundungsfehler bei Fliesskommazahlen).
moorhahn ist offline   Mit Zitat antworten
Alt 15.11.2003, 08:11   #9
darthmaul
Dark Force User
 
Benutzerbild von darthmaul
 
Registriert seit: 25.05.2000
Alter: 56
Beiträge: 61


Standard InStr

Probier mal die InStr-Funktion:

Instr("Atari","ri") sollte dann 4 ergeben,
d.h. wenn ein String nicht enthalten ist,
wird 0 zurückgeliefert.

Grüsse
dARTHmAUL
darthmaul ist offline   Mit Zitat antworten
Alt 15.11.2003, 11:08   #10
_m3
Inventar
 
Registriert seit: 24.09.2001
Beiträge: 7.335


Standard

http://support.microsoft.com/default...b;en-us;301264
Zitat:
HOW TO: Match a Pattern Using Regular Expressions and Visual Basic .NET
This article demonstrates how to create and use regular expressions to determine whether strings match certain patterns. Regular expressions allow for easy parsing and matching of strings to a specific pattern. Using the objects available in the RegularExpressions namespace, you can compare a string against a given pattern, replace a string pattern with another string, or retrieve only portions of a formatted string. In this example, we will construct a pattern to validate a e-mail address.
http://msdn.microsoft.com/library/de...xpressions.asp
Zitat:
.NET Framework Regular Expressions
Regular expressions provide a powerful, flexible, and efficient method for processing text. The extensive pattern-matching notation of regular expressions allows you to quickly parse large amounts of text to find specific character patterns; to extract, edit, replace, or delete text substrings; or to add the extracted strings to a collection in order to generate a report.
...

http://www.microsoft.com/downloads/d...displaylang=en
Zitat:
Featured Highlights

* The "Simple Samples" tab is a good introduction to the use of regular expressions. You can see how to find the first occurrence of a number in a string, as well as try out increasingly difficult examples of field validation.
* The "Screen Scrape" tab shows off more advanced uses of regular expressions. You can enter a Web address and view the links or images contained therein. HTML tag attributes are displayed in a ListView control. You can double-click an image to view it, or double-click a link to open Internet Explorer and view the page.
* The "RegEx Tester" tab provides a convenient way for you to experiment with regular expressions. It also demonstrates how to do search and replace and string splitting.
http://www.microsoft.com/downloads/d...displaylang=en
Zitat:
Each textbox inherits a base "RegExTextBox" class. This class is responsible for validating the contents of a text box against a given regular expression.Featured Highlights

* Inheritance is used to modify the behavior of an existing control (the TextBox).
* The controls on this form utilize anchoring so that the form resizes intelligently without the developer having to write any code.
* When the user clicks the "Validate" button on the main form, the code loops through the controls collection to find all the RegExTextBox controls, then casts them to that base type to call their IsValid method.
____________________________________
Weiterhin zu finden auf http://martin.leyrer.priv.at , http://twitter.com/leyrer , http://www.debattierclub.net/ , http://www.tratschen.at/ und via Instant Messaging auf Jabber: m3 <ät> cargal.org .
_m3 ist offline   Mit Zitat antworten
Antwort


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 21:33 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag