Jump to content
Xtreme .Net Talk

JumpsInLava

Avatar/Signature
  • Posts

    55
  • Joined

  • Last visited

1 Follower

JumpsInLava's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi All, Is there a way to get System.DateTime.Now, and covert the time in to the different Time Zones?
  2. Doh! Thanks all. I guess I learned the hard way, and the easy way. :D
  3. Logic check. Is this correct? Dim iMltryHour As Integer = 14 Dim iMltryMinute As Integer = 23 Dim iCvlnHour As Integer = 12 Dim iCvlnMinute As Integer = iMltryMinute Dim strCvlnAMPM As String = "AM" If iMltryHour = 0 Then iCvlnHour = "12" strCvlnAMPM = "AM" ElseIf iMltryHour < 12 Then iCvlnHour = iMltryHour strCvlnAMPM = "AM" ElseIf iMltryHour = 12 Then iCvlnHour= "12" strCvlnAMPM = "PM" Else iCvlnHour = iMltryHour - 12 strCvlnAMPM = "PM" End If
  4. Dim proka As New Operatie
  5. I guess that wouldn't be worth it for just a few additions. Oh well, back to regular old functions and subs in a library module. Thanks all.
  6. I understand most of the overloading concept, and was wondering how far I could take it. Could I overload the String.Replace method? Example: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim s As String = "this that this that this that" Dim ht As New Hashtable ht.Add("this", "was") ht.Add("that", "there") 'Pass a hashtable into my own overloaded replace. s = s.Replace(ht) End Sub 'How would I declare this? Public Overloads Function Replace(ByVal ht As Hashtable) As String Dim strReturn As String 'strReturn = ? 'Loop through replacing keys w/values Dim o As DictionaryEntry For Each o In ht strReturn = strReturn.Replace(o.Key, o.Value) Next Return strReturn End Function [/Code] I wouldn't really have a use for this, its just an example I came up with to show the type of overloading I am talking about. Is this possible? ...
  7. Woops, shouldn't Dim in the Try block.... Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\ares\mis\data.mdb") MyConnection.Open() Dim MyCommand As New OleDbCommand("SELECT * FROM MyTable WHERE ID = 1", MyConnection) Dim MyReader As OleDbDataReader Try MyReader = MyCommand.ExecuteReader() Catch ex1 As System.Data.OleDb.OleDbException MessageBox.Show(ex1.Message) Catch ex2 As Exception MessageBox.Show(ex2.Message) End Try While MyReader.Read Lastname.Text = MyReader("MyFName") FirstName.Text = MyReader("MyLName") Address.Text = MyReader("MyAddress") End While MyConnection.Close() MyReader.Close() MyCommand.Dispose() [/Code] Sorry....
  8. Do this, and see what it tells you. Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\ares\mis\data.mdb") MyConnection.Open() Dim MyCommand As New OleDbCommand("SELECT * FROM MyTable WHERE ID = 1", MyConnection) Try Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader() Catch ex1 As System.Data.OleDb.OleDbException MessageBox.Show(ex1.Message) Catch ex2 As Exception MessageBox.Show(ex2.Message) End Try While MyReader.Read Lastname.Text = MyReader("MyFName") FirstName.Text = MyReader("MyLName") Address.Text = MyReader("MyAddress") End While MyConnection.Close() MyReader.Close() MyCommand.Dispose() [/Code]
  9. I'm bored again today.... Dim strFileName As String = "C:\File.txt" Dim strFileData As String = String.Empty Dim iStart As Integer = 0 Dim iReadLen As Integer = 0 'Read the file data Dim tr As System.IO.TextReader tr = IO.File.OpenText(strFileName) strFileData = tr.ReadToEnd tr.Close() 'I like trim strFileData = strFileData.Trim 'You have two line breaks (CrLf) between the header and the body. 'Look for them, and set the start position right after them. iStart = strFileData.IndexOf(vbCrLf & vbCrLf) + 4 'This is how much data you want to read after the start position. iReadLen = strFileData.Length - iStart 'Read from position iStart for iReadLen positions. strFileData = strFileData.Substring(iStart, iReadLen) 'Write the file back out. Dim tw As System.IO.TextWriter tw = IO.File.CreateText(strFileName) tw.Write(strFileData) tw.Flush() tw.Close() [code=visualbasic]
  10. Your original code didn't work, because you were using the plus instead of the ampersand. Dim iDowStart As Integer iDowStart = DateTime.Parse(Now.Year & "/" & Now.Month & "/01").DayOfWeek Note: Sunday = 0 If you want to be one based then: iDowStart += 1
  11. This seems like it should be pretty simple, but I can't figure it out for some reason. I have two tables. One is a history table (local Access DB), and one is a lookup table (Stored in a SQL server). tHistory .....DateTime .....HistDescription .....PageID tPageLookup .....PageID .....PageDescription I have them both in a DateSet, and I've set up a DataRelation on the PageID. Now, how do I relate/join/view them together in the dataset so I can display them in a DataGrid that would look like this: DateTime | HistDescription | PageDescription ..........or is it a function of the DataGrid?
  12. Hmmmmm. Interesting. Thank you for the response.
  13. May be an better question would be: In ASP.NET, is each client session its own "application" on the server, or is each client session multi-threading from the same code on the server?
  14. I have an asp.net module that does stuff kind of like this: Module Stuff Dim strHold As String = String.Empty Public Sub subDoStuff(ByVal strString As String) 'Added SyncLock do to paranoia SyncLock GetType(Stuff) 'Clears strHold strHold = String.Empty 'Calls subProcess that does some stuff with strHold subProcess() 'Does some more stuff with strHold strHold &= strString 'Writes strHold somewhere End SyncLock End Sub Private Sub subProcess() 'Adds some stuff to strHold strHold = "This and that" End Sub End Module I saw some samples that used SyncLock, got paranoid, and added it to all of my modules that use any type of globals. (I know global variables are the root of all evil, and will cause nations to collapse, but they sure are handy some times.) Question 1: Do I need to use SyncLock? Question 2: If so, should I use "SyncLock GetType(strHold)" instead?
×
×
  • Create New...