|
I appreciate the answer. I had already figured it out. I used a parameter field instead.
It better suits my program for the user to be prompted for a memberID. Hey if you get a
chance read my newer post.
|
|
|
|
|
Hi,
Is it possible to use special characters like \n or \t in a VB.NET string, just like in C#? My guess is NO, but maybe there's something I don't know.
If it's not possible, does anybody know of a VB.NET function (somebody must have coded this already) that will interpret strings containings those special characters, and handle them the same as in C#?
Thanks!
|
|
|
|
|
The special characters your talking about don't have any meaning in VB.NET. There's not class that will translate them for you either. You'd have to write it. Some using RegEx should work nicely. But check into the ControlChars[^] for the equivelents to the special characters your talking about.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes there is
For the record... this works WONDERFULLY WELL!
MsgBox(System.Text.RegularExpressions.Regex.Unescape("Hello world!!!\n\nHave a nice\tday!"))
|
|
|
|
|
Hmmm... I never knew it was even there. I've never had a reason to use anything like it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how can i use the 'or' function. I want that if the user didn't enter a specific username ex: liba or demel or pufta! how can i do this?? i am using this but it aint working:
If text = "pufta" Or "demel" Then
MessageBox.Show("You have registered for the program. Now close the registration menu and start using the program. Have Fun!!", _
"Registration Completed", MessageBoxButtons.OK, MessageBoxIcon.Information)
s.WriteLine(txtbox.Text)
s.Close()
End If
Adrian
|
|
|
|
|
Or doesn't work like that. Below is how or works.
if text = "pufta" or text = "demel" then
'do stuff
end if
if case doesn't matter (D and d are the same), I would use the following:
if string.compare(text, "pufta", true) = 0 _
or string.compare(text, "demel", true) = 0 then
'do stuff
end if
|
|
|
|
|
If textbox1.text = "pufta" Or "demel" Then
MessageBox.Show("You have registered for the program. Now close the registration menu and start using the program. Have Fun!!", _
"Registration Completed", MessageBoxButtons.OK, MessageBoxIcon.Information)
s.WriteLine(txtbox.Text)
s.Close()
End If
I think you were missing the bold part....
|
|
|
|
|
|
Mr. Dave.. the client ll be having the VB.NET interface from which he ll be accessing the contents (audio, video, text, PDFs etc) located on the server...
as i told u before only, not having much idea abt VB.net and MSSQL Server...
so i would like to know whether the transaction as i told above ll be possible or not ?? as we ll be using Windows Media Player, Microsoft Word and the respective components for the desired contents...
and once again..thanks for ur ideas n info
|
|
|
|
|
It's possible. Your VB.NET app would have to get the path to the file from your SQL database, get the path for the root of your media storage files, combine the two paths together to form a complete path to the file on the server, then just launch it. Simple...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello, i am using the stream reader and writer to write on a textfile. When i am sending this program to my friend he is gaining problems. because the root of the textfile is different from mines. how can i make it to make the textfile somewhere good for everybody to work the program well.
Adrian
|
|
|
|
|
"Root of the textfile"? In what directory are you putting this text file? What's the file used for? Is it shared between all users of the machine?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This textfile is for: my program is to be registered first and i made it, when you click on the button register, automatically the text that has been inputed into the textbox will be transported in the textfile. then when the second time the user opens the program the program will check if theres something in the textfile. if the textfile is not empty then you dont need to register the second time.
This is my register button:
Private Sub btnreg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreg.Click
Dim sw As String = ("C:\Adrian\Registration Test\Register.txt")
Dim s As System.IO.StreamWriter = New System.IO.StreamWriter(sw)
Dim obj As frmprogram
Dim text As String
text = txtbox.Text
If text = "" Then
MessageBox.Show("Invalid Entry", "Registration Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
s.Close()
End If
If text = "" = False Then
MessageBox.Show("You have registered for the program. Now close the registration menu and start using the program. Have Fun!!", "Registration Completed", MessageBoxButtons.OK, MessageBoxIcon.Information)
s.WriteLine(txtbox.Text)
s.Close()
End If
End Sub
End Class
Then this is the program form which will read from the textfile:
Private Sub frmprogram_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Dim obj As New Registration
Dim obj1 As frmprogram
Dim sw As System.IO.StreamReader
sw = New System.IO.StreamReader("C:\Adrian\Registration Test\Register.txt")
Dim s As String
s = sw.ReadLine
sw.Close()
If s = "" = True Then
obj.ShowDialog()
End If
If s = "" = False Then
lbltop.Text = "Hello" & " " & s
End If
End Sub
End Class
|
|
|
|
|
You'll have to put the registration file somewhere where a member of the Users group has write permissions. Most of the time, that's the users own home directory under Documents and Settings. But, you'll have to get creative and hide the registration file somewhere else. File based registrations are weak at best. What's to stop any person from just copying the file to another workstation and breaking your registration?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I dont think this wouldbe to difficult but can anyone provide me a piece of code to do this: I would like the end result to look like this:
ID,MyName,MyAddrerss,MyAge ect...
|
|
|
|
|
Here is one possible method to write a DataTable to a csv file. If you want to write out a whole
DataSet to csv files, then you could loop through each table in your DataSet and produce
a file for each table.
Hope this helps
Public Sub WriteCsv(dt as datatable, filename as string, delimiter as char)
dim writer as System.IO.StreamWriter
try
writer = new System.IO.StreamWriter(filename)
'write the column names
for i as integer = 0 to dt.Columns.Count - 1
writer.write(dt.Columns(i).ColumnName)
if i <> dt.Columns.Count - 1 then writer.write (delimiter)
next
writer.write(controlchars.newline)
'write the data
For i As Integer = 0 To dt.Rows.Count - 1
For j As Integer = 0 To dt.Columns.Count - 1
writer.Write(dt.Rows(i).Item(j))
If j <> dt.Columns.Count - 1 Then writer.Write(delimiter)
Next
if i <> dt.Rows.Count - 1 then writer.Write(ControlChars.NewLine)
Next
writer.Flush()
writer.Close()
writer = Nothing
Catch ex As Exception
If Not writer Is Nothing Then
writer = Nothing
End If
End Try
End Sub
|
|
|
|
|
Nice one worked a treat..
|
|
|
|
|
Hello
I have a asp.net datagrid with 4 bound columns and an item template column with an image button control. all these columns have the same datasource, i can bind the 4 bound columns just fine to their apporiate columns in the datasource but i am at my wits end as to how to get the correct image url's for all the image buttons in the item template. Please help it's rather urgent
Thank you
|
|
|
|
|
Your question wuold be better handled in the ASP.NET Forum. It has nothing to do with VB.NET...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
|
Hi!
I have a collection where i keep objects of a certain type.From time to time i need to enumerate the collection and access some properties of that object to know if that object is obsolete and remove it from the collection. Many threads manipulate those objects, ones for reading others for writing.
My question is: to assuere thread-safety should i lock the collection or the current Object being processed? I ask this because even though the collection is locked if another thread changes the object directly the lock to the collection is useless!!!
Anyone can help me with this?
Another question: if i have a synchronized version of the collection, if another thread modifies the collection through a synchronized version of the collection will it afect the first thread?
thx in advance
Never say never
|
|
|
|
|
If you synchronize access to the collection, the thread that gets to the collection second will block until the first thread releases its lock.
As is plastered all over the .NET Framework documentation, enumerating a collection is not a thread-safe operation. From the Array class documentation:
Thread Safety
Public static (Shared in Visual Basic) members of this type are safe for multithreaded
operations. Instance members are not guaranteed to be thread-safe.
This implementation does not provide a synchronized (thread-safe) wrapper for an Array;
however, .NET Framework classes based on Array provide their own synchronized version of the
collection using the SyncRoot property.
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a
collection is synchronized, other threads could still modify the collection, which causes the
enumerator to throw an exception. To guarantee thread safety during enumeration, you can either
lock the collection during the entire enumeration or catch the exceptions resulting from changes
made by other threads.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi!
But in order for the second thread to stay blocked i need to put the code in the first thread protected by a syncLock block right?
Never say never
|
|
|
|