|
I need the following format: @@-@@@@-@@
I know you do the following with something that is a numeric value:
microsoft.VisualBasic.Format(12345678, "##-####-##")
What do you do if you have an alphanumeric string and you want the same format? Is there a way to do this without parsing the string? I realize I'm probably missing something simple here.....
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Not pretty, but it works...
microsoft.VisualBasic.Format(cdbl("12345678"), "##-####-##")
|
|
|
|
|
Thanks for the reply,
I should have been more specific in my example. The VB.Format function will work with numeric values like you pointed out, but what do you do with alphanumeric values.
Suppose I want to format: "AB1234Z7" in the same format (@@-@@@@-@@)?
Is there a built in way to accomplish that or do you need to manually parse the string and build a new one?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Any of C.P.s finest have an answer for poor ol' me?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
The most efficient way, I think, is to use a StringBuilder:
Dim formatted As String = New StringBuilder(10) _
.Append(alphaNumeric.Chars(0)) _
.Append(alphaNumeric.Chars(1)) _
.Append('-') _
.Append(alphaNumeric.Chars(2)) _
.Append(alphaNumeric.Chars(3)) _
.Append(alphaNumeric.Chars(4)) _
.Append(alphaNumeric.Chars(5)) _
.Append('-') _
.Append(alphaNumeric.Chars(6)) _
.Append(alphaNumeric.Chars(7)) _
.ToString()
The StringBuilder uses an internal string buffer, and the ToString method will return that buffer as a regular string, so there is no extra copying going on. As you define the correct size when creating the StringBuilder, there will be no reallocation of the buffer or unused overhead at the end of the string.
Another method is to use a regular expression. It's not as efficient, but fairly short:
Dim formatted As String = Regex.Replace(alphaNumeric, "(.{2})(.{4})(.{2})", "$1-$2-$3")
Despite everything, the person most likely to be fooling you next is yourself.
modified on Thursday, August 28, 2008 5:15 PM
|
|
|
|
|
Guffa wrote: The most efficient way, I think, is to use a StringBuilder:
I'll give something like this a go.
Guffa wrote:
Another method is to use a regular expression. It's not as efficient, but fairly short:
Nice! I thought regex's could only check data, not update it. Sigh....
Thanks Guffa for pointing me back into the light.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
How can i make sure that no one can kill the process of my window service
|
|
|
|
|
Can't. A user with administrator privileges can kill the process or just stop the service.
|
|
|
|
|
|
Ok if this is not possible then is there a way that i can restart the service if it is stopped or shutdown.
|
|
|
|
|
hello...
i have a combobox and a datagrid...i have contents of f_name displayed in combobox from database...so when i select name from combobox it should display all the data of that particular name...but in my grid only columns are displayed...they are blank....neeeeeeed help!!!!!!!
|
|
|
|
|
seee this
http://www.codeproject.com/KB/cs/N-Tier22.aspx[^]
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hello frends .......
m facing problem while trying to insert values into the database using dataset and tablemapping...... getting error no coloumn at index 0
Dim ds As New DataSet
ds.Tables.Add("DATA")
Dim dr As System.Data.DataRow
Dim k As Integer
' For i = 1 To 90
Dim m As Integer
' m = i
m = 1
k = 0
' Dim t As TextBox = Panel2.FindControl("Text" & i.ToString())
' If t.Visible = True Then
dr = ds.Tables("DATA").NewRow()
dr(k) = Session("proj")
k = k + 1
dr(k) = Session("vol_name")
k = k + 1
dr(k) = Session("brd")
k = k + 1
For j = 1 To 9
If j = 4 Then
Dim d1 As DropDownList = Panel2.FindControl("Text" & m.ToString())
m = m + 1
dr(k) = d1.SelectedValue
k = k + 1
Else
Dim t1 As TextBox = Panel2.FindControl("Text" & m.ToString())
m = m + 1
If t1.Text.Trim() = "" Then
dr(k) = OracleString.Null
k = k + 1
Else
dr(k) = t1.Text.Trim()
k = k + 1
End If
End If
Next
ds.Tables("DATA").Rows.Add(dr)
' Else
' Exit For
' End If
' i = i + 8
' Next
'*******************************
Dim cn As OracleConnection
cn = New OracleConnection("user id=lntforms;data source=;password=user123")
cn.Open()
Dim sq1 As String
sq1 = "SELECT * FROM CMS_LOADLIST"
Dim oraDa As OracleDataAdapter
oraDa = New OracleDataAdapter(sq1, cn)
oraDa.TableMappings.Add("Load_list", "DATA")
oraDa.Fill(ds, "CMS_LOADLIST")
'Label5.Text = ds.Tables("DATA").Columns.Count.ToString()
Dim cb As OracleCommandBuilder
oraDa.SelectCommand = New OracleCommand(sq1, cn)
cb = New OracleCommandBuilder(oraDa)
Try
oraDa.Update(ds, "DATA")
ds.AcceptChanges()
'Session.Add("ds", this.ds)
Catch ex As System.Exception
'err = 1
ds.RejectChanges()
'Session.Add("ds", this.ds)
If ex.Message.StartsWith("ORA-00001") Then
Label5.BackColor = Color.Red
Label5.Text = "All project entries must be unique."
Else
Label5.BackColor = Color.Red
Label5.Text = ex.Message()
End If
End Try
please help me out....
kisran
|
|
|
|
|
i want to work on something that manages staff time schedule. the rows indicate the time and the columns indicate the staff/employee. the logic of my app is when the start an end time is inputed it will color the datacells affected and show the details of the employee task. my problem is the details will appear on every datacell it will affect. is there a way in vb.net that same cells will be merged displaying a single values? i have seen an application in vb6 that display in datagrid what i need. here is the image:
http://img357.imageshack.us/img357/5510/datagridus2.th.jpg[^]
the image show same dates merged into a single cell and displays a single value. hope there is a way in vb.net. ive tried to search for it in the web, i cant find any samples of it.
modified on Thursday, August 28, 2008 2:43 AM
|
|
|
|
|
Please do not cross post, its rude.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
|
Hi
I am using the following code to retrieve an HTML page contents but it is throwing an exception for certain page of javascript type. Following is the code used to retrieve the page.
Dim objWebClient As New WebClient()
Dim objUTF8 As New System.Text.UTF8Encoding()
Dim strRequestHTML As String
strRequestHTML = objUTF8.GetString(objWebClient.DownloadData(New Uri("http://search.live.com/results.aspx?q=basic")))
Here the error is thrown while downloading the data that an unspecified error occurred at line #.
I want to suppress this error, please suggest me any mod which could do the trick. I would be so thankful to you.
Thanks and Regards,
MAP Tiger
Tiger Softwares
Software Designer and Developer
VB.NET, ASP.NET, VFP
|
|
|
|
|
Try to supply request headers as a valid JS supported browser. This may avoid JS errors. I don't think that you can suppress it.
|
|
|
|
|
Hi
Thanks for the reply.
Can you please give me an example?
Regards,
MAP Tiger
Tiger Softwares
Software Designer and Developer
VB.NET, ASP.NET, VFP
|
|
|
|
|
Hi guys
I just have analyzed that the problem is not in this procedure but the upcoming syntaxes are throwing the error:
Dim aDoc As IHTMLDocument2 = New HTMLDocumentClass()
aDoc.write(strRequestHTML)
aDoc.close()
I am using this procedure to access all the elements of the downloaded HTML page and the error throws at aDoc.write(strRequestHTML) and I think it is because there are javascripts which are supposed to be loaded but the current implementation is not letting it loaded so the functions which are using them are of course left undefined which in turn throwing the error.
Please help me in this regard, I would be so thankful.
Regards,
MAP Tiger
Tiger Softwares
Software Designer and Developer
VB.NET, ASP.NET, VFP
|
|
|
|
|
since you have the string you can prepend to it:
<script language="JavaScript" type="text/javascript"> <!--
function stoperror(){return true}
window.onerror=stoperror
// -->
</script>
This will suppress the javascript errors, if that is what is causing the problem.
|
|
|
|
|
Hello All;
Forgive me for cross posting but I'm not getting any answers from the SQL group.
I have a SQL db that collects environmental data. As it gets larger the performance of the server suffers. So I think that I would like to copy the "working" db to a new db then purge the working db. The be able to run querrys that span the databases.
I would like to do this using VB.net
I have been able to backup the db. Cant seem to get the DROP and Restore to work keeps telling me the the db is in use. Which is why I thought I had to do the DROP??
Haven't been able to find any info on the "bulk" copy or rename issue or the purging of the working db but I'm still researching it.
As an example.
If we backed up the db monthly and renamed them lets say to the month and year name. Then purged the working db. Would it later be possible to run querry's that spanned the db's.
1. Is this a doable concept?
2. Would I?
"Drop" the working db
Copy all the data from the working db to a new db
Purge the tables in the working db
Just looking for some conceptual help here to make a plan to do this. Any help or guidence you could give be would be greatly appreciated.
I have found info on the SQL DMO but because I have 2005 enterprise, 2005 express, 2000 enterprise and MSDE box's I have been trying to do this in pure VB/ADO. Is this valid reasoning for not using SQL DMO?
I have not been able to find enough usable info on doing this kind of stuff with vb.net.
tia
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
You may want to try implementing a paging grid, or something along those lines if you are pulling a bunch of rows from a table...
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
Rafone wrote: Forgive me for cross posting but I'm not getting any answers from the SQL group
Yes you did, I suggested looking at partitioned tables and someone else suggested using replication.
By the read of your post you are going to end up losing all your data. Its not necessary to create other databases, you may want to archive your data to other tables. SQL Server is quite capable (on decent hardware) of handling terrabytes of data.
If you are having performance issues then
Rafone wrote: I have found info on the SQL DMO but because I have 2005 enterprise, 2005 express, 2000 enterprise and MSDE box's I have been trying to do this in pure VB/ADO. Is this valid reasoning for not using SQL DMO?
I have not been able to find enough usable info on doing this kind of stuff with vb.net.
You really do not want to be doing this sort of thing from VB, it should be done directly on the server.
I strongly advise you get someone in who really understands SQL Server to advise you, otherwise it looks to me like you are going to end up in a real mess.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanks for the suggestions.
Because of some FDA requirements I am required to give them monthly backups. I have been doing this from the server for the last 5 years. I was and am looking for an automated way of doing this.
Just trying to get some other opinions of how to go about it.
Thanks for the info.
Rafone
PS havn't lost any data yet....
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|