|
You're welcome.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
I'm trying to remove the ® and ™ symbols in a string using Regex and it doesnt work for the ™ symbol.
Here is some example code:
Dim s1, s2, s3 As String
Dim i As Integer
s1 = "Trademark" + Chr(153) + " Registered" + Chr(174)
s2 = System.Text.RegularExpressions.Regex.Replace(s1, "[\x99]", "(TM)")
s3 = System.Text.RegularExpressions.Regex.Replace(s1, "[\xAE]", "(R)")
Debug.Print("Orig: " + s1)
For i = 0 To s1.Length - 1
Debug.Print(" " + s1.Substring(i, 1) + " " + Asc(s1.Substring(i, 1)).ToString("X") + " " + Asc(s1.Substring(i, 1)).ToString)
Next
Debug.Print("S2 : " + s2)
Debug.Print("S3 : " + s3)
This code seems to work for the (R) symbol, but not the (TM).
However, if I use Chr(153) instead of \x99 in the regex call, the code works fine.
What am I doing wrong?
Thanks.
|
|
|
|
|
chr() and asc() are ancient ANSI-oriented functions.
A little experiment taught me chr(153) generates unicode character x2122.
Using AscW() rather than Asc() would reveal the truth about your strings.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Hi,
I have data in Access Database which I am filling in the DataGridView to QA/QC raw data downloaded from a climate station. I am having trouble updating the database using update command. I am using following steps:
1. Locating access database:
Private Sub AccessDataFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AccessDataFileButton.Click
OpenFileDialog2.Filter = "Microsoft Access File(*.mdb)|*.mdb|Microsoft Access File(*.accdb)|*.accdb|All files (*.*)|*.*"
OpenFileDialog2.Title = "Input Data File with Real-time Water Quality Time Series"
If OpenFileDialog2.ShowDialog = DialogResult.OK Then
accessDataFile = OpenFileDialog2.FileName
'MsgBox("accessFile= " & OpenFileDialog2.FileName)
Me.AccessFileTextBox.Text = accessDataFile
End If
End Sub
2. Filling DataGridView:
Sub fillDataGrid1()
' Read Access Table to find date and time of the last data
Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & accessDataFile
Dim myConnection As OleDbConnection = New OleDbConnection
myConnection.ConnectionString = connString
myConnection.Open()
Dim inpTable As String = "rawClimateData" 'Access database table
Dim cmd As String = "Select * from " & inpTable '& " ORDER BY mdateTime"
Dim dbCmd As OleDbCommand = New OleDbCommand(cmd, myConnection)
' create a data adapter
Try
da = New OleDbDataAdapter(cmd, myConnection)
Catch ex As Exception ' Catch the error.
MsgBox(ex.ToString) ' Show friendly error message.
End Try
' create a new dataset
Dim table As New DataTable
myDataset = New DataSet()
Try
Me.da.Fill(table)
da.Fill(myDataset, inpTable)
Me.DataGridView1.DataSource = table
Catch ex As Exception
MsgBox(ex.ToString)
End Try
myConnection.Close()
End Sub
3. Updating database (update button)
Private Sub TryTry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles upDate.Click
Try
Me.da.Update(Me.myDataset.Tables("rawClimateData"))
Me.myDataset.AcceptChanges()
Catch ex As Exception
MsgBox(ex.Message)
End Try
MsgBox("upDateComplete")
End Sub
In some examples I have seen connecting database file while Form is loading; however, I have an option of browsing the access database file.
I know it should be simple, however, I am not a pro. Therefore, any tips/help would be greatly appreciated.
Cheers,
Amanjot
|
|
|
|
|
"AcceptChanges[^]" only updates the object in memory, not the database itself.
I'd suggest you fire an UPDATE statement whenever you want to change something, or an INSERT if you want to add a tuple.
Bastard Programmer from Hell
|
|
|
|
|
I have a table. It desn't have any Id which will be generated automatically.
my table (Table1)has 30 some rows and 3 columns(FirstName, LastName, Occupation).
I want to read each row one by one and wanted to create a unique ID which is of type uniqueIdentifier and fill another table with all these coulmns and newly created ID.
How can I do that
|
|
|
|
|
you haven't said what the database is
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Either Paradox 5.0 or DBaseIV format - which would you recommend?
Bastard Programmer from Hell
|
|
|
|
|
Daffodil database[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
EDIT: Sorry I misread the question.
Could you iterate through the collection
For i As Integer = 0 To table.count - 1
Dim selected As Row = table.row(i)
newTable.add(New Row(i, selected.FirstName, selected.LastName, Occupation))
Next
Alternatively if you are adding to existing table you could use a GUID
For i As Integer = 0 To table.count - 1
Dim selected As Row = table.row(i)
newTable.add(New Row(Guid.NewGuid(), forstName, LastName, Occupation))
Next
- Use the database primary key and store in a column those width is 0.
- Some table rows have a tag property you can use to store the entity representing the record
- Some tables are bound directly to a data source, so by querying the selected row, you can access the unique Id.
For a more specific answer, you'll need to detail the scenario. At this stage we don't even know if your talking about a DataGrid, a DataTable or some other matrix type object.
"You get that on the big jobs."
|
|
|
|
|
I have a table. It desn't have any Id which will be generated automatically.
my table (Table1)has 30 some rows and 3 columns(FirstName, LastName, Occupation).
I want to read each row one by one and wanted to create a unique ID which is of type uniqueIdentifier and fill another table with all these coulmns and newly created ID.
How can I do that
|
|
|
|
|
Why row by row, and not all at once?
SELECT NEWID()
, [FirstName]
, [LastName]
, [Occupation]
INTO MyNewTable
FROM MyExistingTable
--edit;
You would have received more answers if you posted this in the Database[^]-forum.
Bastard Programmer from Hell
|
|
|
|
|
That is according to MSDN[^]
I don't understand is... why? I am sure the answer is probably very simple, but for some reason my mind can't come up with the answer. Maybe it's cuz I am so frustrated with this error. Well, who knows.
What do I want to achieve?
Suppose the following...
Public Sub ChangeThePictureBoxBC(Optional newColor as System.Drawing.Color = Drawing.Color.Black)
Me.SomePictureBox.BackColor = newColor
End Sub
This does not seem wrong to me. Can someone please explain A) why the above sub is wrong without re-quoting the unhelpful MSDN document and B) what suggestion/advice can you give me to make an optional parameter that involves color.
Thanks in advance.
|
|
|
|
|
Clark Kent123 wrote: A) why the above sub is wrong
Only nullable types can be used as optional parameters; a struct is a value-type and can't be empty.
Clark Kent123 wrote: B) what suggestion/advice can you give me to make an optional parameter that involves color.
Overloading[^], instead of optional parameters;
Public Overloads Sub ChangeThePictureBoxBC(newColor as System.Drawing.Color)
Me.SomePictureBox.BackColor = newColor
End Sub
Public Overloads Sub ChangeThePictureBoxBC()
Me.SomePictureBox.BackColor = Drawing.Color.Black
End Sub
Bastard Programmer from Hell
|
|
|
|
|
Overloading! Yeah, that's probably the direction that I will go in. Great suggestion!
|
|
|
|
|
Thanks
|
|
|
|
|
I'm reading a range from VBE code in a spreadsheet.
data = mySheet.Range(a1:a8).value
but I need to get data as Double() and not as Variant
I need something like:
Dim data() as Double
data = mySheet.Range(a1:a8).value
this because I will use data as c# arg of Com addins (double[])
Thanks for your time
|
|
|
|
|
TheGermoz wrote: this because I will use data as c# arg of Com addins (double[])
I haven't scripted that much yet, but wouldn't it be easier to change the params of the Com addins to (object[])?
Put a breakpoint on it, and see if you can cast/convert it to double's.
Bastard Programmer from Hell
|
|
|
|
|
thanks you for your replay. Com addin is shared with other application. so not so easy.
It is surprising that from VBE code in spreadsheet it is not possible to copy an Excel range into an array of double() with one dimension.
|
|
|
|
|
TheGermoz wrote: data as Double() and not as Variant
Have you tried Array.Copy?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Array.Copy() is not available from VBE but from VBA/C#, so I need to change the COM addin..that is shared with other application...
|
|
|
|
|
How to Convert MS Word 2003 doc to PDF
|
|
|
|
|
|
|
I am currently in the process of learning the vb.net environment after spending a number of years using VB6.
I took one of my straight forward single threaded apps in VB6 and used the upgrade wizard to convert this app to .net. I've got most of the conversion issues resolved, but I am now getting messages warning about accessing objects from a thread different than the one that created the object. So I'm a bit confused since the original VB6 app - which works fine by the way - had only one thread.
Why am I getting these sorts of messages? I've searched through the code - with my limited exposure to multithreading - and not found anything obvious that I've somehow created a Hydra from a single snake.
My preference would be how to "just make it simple" - a single threaded .net app. All of the references I find to multithreading talk about how to do it. I really - at least at this point - want to know how to avoid it.
I know that soon I will wade in and learn multithreading, but I'd like to do it on my terms.
Any ideas? Pointers to some reference material?
Thanks,
Rick
|
|
|
|