|
Hi all,
I need that application I'm developing can consider the same (=), 3 strings for example like these:
String A = "This, is, a, sample, 12345"
String B = "this, is,a, Sample ,12345"
String C = "This,is,a,sample,12345"
Someone know if there is a simple way (may be a single instruction?) to do that?
I know how to do that, but it is not a simple way.
Thanks
Ignazio
modified on Saturday, September 12, 2009 2:09 PM
|
|
|
|
|
your question is unclear. IF what you want is a way to compare two strings ignoring white space, ignoring comma's and ignoring case, then the solution is two write a function MyStringCompare(ByVal string1 as String, ByVal string2 as String) as Integer wherein you first remove white space and comma's, and then use the built-in string compare function, telling it to ignore case.
If that is unclear to you, I strongly advice you to buy and study a book on the programming language of your choice.
|
|
|
|
|
Hi,
Yes, I need a way to compare 2 strings, ignoring spaces and case.
In the end of my question, I written that I know how to do that, but I was hoping that someone know a simpler way, or may be an already built-in instruction in V.B. to do this work.
Thanks for help and for "advice"
Ignazio
|
|
|
|
|
can you explain it little more what is your point if i am not wrong do you want that you have same string but in different cases and spaces and you want it to be consider as same
is this your question or what ????
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
|
You can do a case insensitive comparison easy enough. I don't know there's a way to ignore spaces without actually removing them.
String.Compare takes a bool to say if it's case sensitive.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
That for me has prioritary importance, is the problem of spaces.
The case insensitive comparation is a secondary requirement.
It seems that I can't avoid the work to delete spaces.......
Ignazio
|
|
|
|
|
No, because you're creating an odd definition of 'equal'. You may be able to use regex to create a string that allows arbitrary spaces between each character, but it seems like more work than just stripping them, to me.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks for help,
I will evaluate what is more convenient to do.
Strings that I must compare can have until 23 commas!
Ignazio
|
|
|
|
|
hope so this will work , I did this thing for you but MVPs don't recommend this because copy paste will not enhance your programing skills
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str1, str2 As String
str1 = "softdev_sup"
str2 = "Softdev_ sup"
MessageBox.Show(String.Compare(str1, str2, False))
MessageBox.Show(String.Compare(RemoveSpace(str1), RemoveSpace(str2), True))
End Sub
Public Function RemoveSpace(ByVal strText As String) As String
Return System.Text.RegularExpressions.Regex.Replace(strText, " ", _
String.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
End Function
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Hi,
The code you posted seems to be exactely that I was looking for.
With great surprise, differentely I was thinking, it is also fully compliant with Compact Framework, without any modification.
Running the code, the first message is "1" and second is "0".
To reduce the impact on the programing skills, I will do the work in 2 steps:
A first pass will exclude strings 100% equal (considering also spaces), from the 2nd pass that will compare only remaining strings using the RemoveSpace function.
Thank you very much.
Ignazio
modified on Monday, September 7, 2009 12:44 PM
|
|
|
|
|
u r welcome man say thanks 2 code project
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Dear All,
i am VB.Net User with Visual Studio.Net i want to genrate a project for FM Radio. They have some secrete MP3 files. So, they want to store them in there Data Base.
Dear All my Question is that how can i do that Using Visual Studio with Visual Basic.Net. If Someone has complete knowledge about this so plz help me.
Waiting for ur reply
Abdul Rouf
|
|
|
|
|
storing bulk data is always the same, whether it is one image, one movie, one audio track.
CodeProject has lots of entries on storing images, and so does Google.
|
|
|
|
|
They (you) really want to store the MP3s in the DB? Personally I prefer to store them in the file system and then store meta-data about the files in the DB (ie: keywords, title, musician, etc...) along with the storage location in the file system.
|
|
|
|
|
Hello To all
I have a text box that displays the date and it work my problem is it dont change when the date changes to the next day ??
here is my code Textbox1.text is the text box with the date in it
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
TextBox1.Text = Format(Now, "M")
Timer1.Interval = 60000
Timer1.Start()
Thanks everyone for your help
everyone has been grate here
Bob
|
|
|
|
|
Ask yourself when and how often does Form1_Load execute.
|
|
|
|
|
Thanks Luc i shold have no that hehe
Thanks to good pepole like your self
pepole like me can lern vb
This is what i did to fix it and it seems to work
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
TextBox1.Text = Format(Now, "M")
End Sub
Thanks agine for every one help
|
|
|
|
|
I want to create "views" of a web page, to do that I´m retrieving and editing the html code to show what I want in a new small webbrowser:
Dim PageHTMLBytes() As Byte
Dim htmlText as string = ""
PageHTMLBytes = webClient.DownloadData(url)
' Convert result from byte array to string
Dim utf8 As New UTF8Encoding()
htmlText = utf8.GetString(PageHTMLBytes)
...
-Edit of the html code-
...
miniWebBrowser.DocumentText = editedhtmlText
The problem is that one part of the editedhtmlText I´m showing, is a flash object which checks if you are logged in, but it doesn´t matter if I logged before, as soon as I set my own, edited code, the session is lost. I tried setting cookies like this:
Dim request As HttpWebRequest = WebRequest.Create("http://www.cam4.com")
'Set cookies.
request.CookieContainer = New CookieContainer()
request.CookieContainer.Add(New Cookie("user", "usuario1", "/", url))
request.CookieContainer.Add(New Cookie("password", "password1", "/", url))
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As IO.StreamReader = New IO.StreamReader(response.GetResponseStream(), True)
Dim html As String = reader.ReadToEnd()
web.DocumentText = html
..which throws no errors but no luck at all in keeping my session. I started to fiddle about with webrequest and responses instead of downloading the html code, but I couldn´t go much further.
I´m on Windows XP 32 bits, VB 2008 Express, Net. Framework 2.0 SP1 (for legacy support). Some assistance on how can I aboard this problem will be appreciated.
|
|
|
|
|
|
Hi all
I am creating a program in which I am executing a bach file, which requires a "Enter key" hit to execute, as below :
Dim prc As New Process
With prc.StartInfo
.FileName = "e:\abc.bat" 'batchfile to execute
.UseShellExecute = False
.RedirectStandardInput = True
End With
prc.Start()
prc.StandardInput.WriteLine("{enter}")
prc.Close()
Now the above code run successfully and it appears a command prompt window showing "e:\abc.bat" file is executing but the code
prc.StandardInput.WriteLine("{enter}") is not redirecting enter key to completely execute the batch file.
How can I use "Enter key" hit on that command prompt window in vb.net.
Thanks.
Gagan
|
|
|
|
|
Lookup Console/StandardInput.ReadLine() or .ReadKey() and test for enter.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks Henry for your suggestion but I have already tried these methods and there is no effect when a command window appears showing "abc.bat" is running.
I only want to do that when my batch file start executing, it takes a "Enter key hit" from program to completely execute my batch file(because it requires a Enter key hit for further execution)and not wait for hitting Enter mannually from user.
Suggest me how can I do that.
Thanks.
Gagan
|
|
|
|
|
Hi,
I hava piece of code which creates a networl drive on the user's system. I need to hide the network.
The purpose of doing this is that the user while using an application need to connect to the Access db on a file server. But shouldn't know that the drive is mapped onhis computer.
Thanks
Sanjeev
Sanjeev
|
|
|
|
|
I may be misunderstanding your problem but doesn't the standard Data Source parameter accept a URI - ServerMachineName\PathOnServer.mdb?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|