|
OmarMallat wrote: but let we say that while my application is running, the user go to the regional setting and change the format manually
Not likely, but it's possible. Changing the system-wide regional settings is usually done only once and left that way. Changing it in the control panel effects the ENTIRE system, not just your applicaiton.
OmarMallat wrote: so my variable still having the old format, and several problems may occur...
In normal applications, it's expected that if a change like this is made, the application must be restarted for the change to take effect. There is no SystemEvent that tells you that the locale was changed.
When your application starts, it starts with the culture settings specified in the Regional control panel. The bigger question is, why is your application switching cultures after it starts?
If the date format is that critical, and NOT tide to the culture settings, why don't you just offer this format as a configuration option in your application. This setting will effect only your application and can be changed at any time.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you very much for your comments.
my application has an options to run with multi interface and culture. and it runs with the last option selected.
I found a problem while converting date, if there is a diffrence between the date format in regional setting and my application.
but if I know that in regional setting, I can convert date as I want without any problems.
now, what I do is that:
when I want to search any date, this date is in the format of the current culture selected by the application, while the database store the date with the regional setting format. this diffrence may cause that the date selected by the user will never be found...
so always, I convert date from my application culture to regional setting format to prevent error.
you have right that if a user change the regional setting format while the application is running, it must be restarted. but if I read the regional setting format with every date conversion, I prevent error, and no need to restart application.
Any way, my problem can be found on this article:
URL : http://www.codeproject.com/script/comments/forums.asp?msg=1301729&forumid=1646#xx1301729xx
please read the first comment to get the right problem.
OmarMallat
|
|
|
|
|
How are you saving the date in the database? As a String...like 12/11/2005? The date shouldn't be saved in ANY culture format, rather the native representation (no format at all) of the database engine.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
the database is with MSACCESS. and the field is with Date/Time data type, and the date will be shown as same as the regional setting.
OmarMallat
|
|
|
|
|
When you view the table in Acces, it's DISPLAYED in the current culture. It's most definately not STORED that way. There is no formatting of a date/time serial number in the database. The only thing you need the culture for is displaying the date/time and accepting date/time input in the correct format. Once you get the date/time into a DateTime object in VB.NET, the culture no longer applies.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I'm trying to print a form in vb6.0, without the background? The option
Printform, prints with the background even if i make forms DrawStyle Transparent. Is there a way to print a forms components as Textbox, Labels without the background????
It's quite urgent!!!
Thanks & Regards!!!
|
|
|
|
|
Hi
I want to generate on Demand Report /Nested Report in Crystal report 8.0 using Visual Basic 6.0 . I genegrate the
on demand report in Crystal report , it work at design mode well, but Calling It from Visual Basic , It works Simple Report , Link does not work .
Can u Suggest me , or Give some code for to solve the problem .
Thanks in Advance.
Manoj
|
|
|
|
|
hi to all
i have datagrid that contain a field with text .
i can not view all the text in the datagrid when i click on it ,
i remmber in vb 6.0 there was an option that when i click on the datagrid i can view it with all the text in the fields , the data grid exspand to height
thxx for anyhelp .
|
|
|
|
|
Try:
textboxname.TextBox.Multiline = True
textboxname.TextBox.ScrollBars = ScrollBars.Vertical
could also use:
ScrollBars.Horizontal
ScrollBars.Both
ScrollBars.None
hope that helps..
|
|
|
|
|
Hi.
Assume that we have an extender control (such as tooltip).
How can we add a Custom TypeEditor for extended property (such as tooltiptext).
Reza
|
|
|
|
|
Can you help me by providng with necessary code
Ravi Pratap
|
|
|
|
|
code:
Dim strme As String = Directory.GetCurrentDirectory
txtStatPath.Text = strme
error:
An unhandled exception of type 'System.NullReferenceException' occurred in foldingathomestatcompare.exe
Additional information: Object reference not set to an instance of an object.
don't know what the heck is going on but when i put it in a msgbox it works but as soon as i try and assign it to a textbox it doesn't work. someone please tell me what is wrong, and at all possible why.
|
|
|
|
|
My guess is that this code is in your constructor (ie: Sub New) just above the InitializeComponent() method. Am I right?
You see, your member variable txtStatPath (which I'm guessing is a TextBox) is assigned a reference in the InitializeComponent() method. Before that method gets called, txtStatPath is initialized to Nothing which would cause that NullReferenceExcepection that you are seeing.
The best place to put this code is in your Form Load event.
|
|
|
|
|
Private Sub frmSettings_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'retrieves settings from registry
getSettings()
'sets default path if not set to current directory
Dim strme As String = Directory.GetCurrentDirectory
txtStatPath.Text = strme
End Sub
as you can see it is not set and it is in the form load, altho this is a form that is loaded after the main form would that make a difference?
|
|
|
|
|
I recommend that you do a search for txtStatPath within your source file. Make sure that you search within all #Regions.
You'll want to make sure that txtStatPath gets assigned. You should see something like...
txtStatPath = New TextBox
|
|
|
|
|
Friend WithEvents txtStatPath As System.Windows.Forms.TextBox
Me.txtStatPath = New System.Windows.Forms.TextBox
Me.Controls.Add(Me.txtStatPath)
i pulled out all the txtStatPath info except for it's size location and such but it was in there.
|
|
|
|
|
Hmmm... it looks like your TextBox member variable is okay.
Have you tried stepping through your code in debug mode? Try placing a break point at the beginning of your Form Load event code and see exactly where your exception is occuring. It might not be crashing where you think it is.
|
|
|
|
|
HI, VB Net used.I have this form that has tree View on the left and a data grid
On the right being fill by a Database Access from a dataset. I have
Already set the connection with Oledb 4.0 making a dataset, and using the following
Request requete = "SELECT * FROM PRODUITS WHERE CATEGORIE = 'Inventaire\Bushing';"
Up to hire OK. I would like to know if it is possible to replace the condition in the WHERE clause like this example 'Inventaire\Bushing';" by a variable like this 'lb1Path.Text. I try this, but it doesn’t work see my example: request
requete = "SELECT * FROM PRODUITS WHERE CATEGORIE = 'lb1Path.Text';"
As you can see what I am trying to do is when I click on one of the tree nodes who
Are by the way Category to put up trough the variable lb1Path.Text. May be there are other ways to do that, if so a lot of help will be appreciate. Thank you
See my code sorry for the French.
Private Sub se_connecter(ByVal requete As String, ByVal table As String)
Dim base, chemin As String
'Chemin d'accès à la b.d. située dans le dossier bin
chemin = Application.StartupPath & "\INVENTAIRE.MDB"
base = "provider=microsoft.jet.oledb.4.0;data source=" + chemin
Dim connexion As OleDbConnection = New OleDbConnection(base)
connexion.Open()
'Lien entre la base et la requête
Dim Liaison As New OleDbDataAdapter(requete, base)
Dim Memoire As New DataSet
'Charge la table en mémoire
Liaison.Fill(Memoire, table)
Dim Vue As New DataView(Memoire.Tables(table))
grille.DataSource = Vue
connexion.Close()
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim node As System.Windows.Forms.TreeNode
node = TreeView1.SelectedNode
lb1Path.Text = sender.SelectedNode.FullPath
'MessageBox.Show(TreeView1.SelectedNode.ToString)
'Dim choix As Byte
Dim requete, table As String
'Sélectionne tout
requete = "SELECT * FROM PRODUITS WHERE CATEGORIE = 'Inventaire\Bushing';"
table = "PRODUITS"
se_connecter(requete, table)
'J’essaiyé ceci mais ca marche pas
requete = "SELECT * FROM PRODUITS WHERE CATEGORIE = 'lb1Path.
|
|
|
|
|
Try out this code:
requete = "SELECT * FROM PRODUITS WHERE CATEGORIE='"& lb1Path.text & "'"<br />
or <br />
requete = "SELECT * FROM PRODUITS WHERE CATEGORIE ='"+lb1Path.text+"';"
I hope it'll work fine
go ahead... happy programming....
Uttam;)
try to be the best... whereever you go,
|
|
|
|
|
I dount there is a way to do this, but does anybody know if i could make a program in VB.Net that will save Word Documents your working on every so often? (I hope you can understand my question)
|
|
|
|
|
Microsoft Word can already do this for you.
Just go to Tools\Options on the menu, select the Save tab, and check "Allow background saves" and "Save AutoRecovery info".
|
|
|
|
|
Hi every body.
I have some problem using date while changing My.Application.culture.
let we say that the regional setting have the date MM/dd/yyyy, and My.Application.Culture have the date dd/MM/yyyy, so any parsing from string to date or from date to string will reverse day and month.
in my project I have a combobox that was be filled using some date from a database. while filling it, all date was converted automatically from MM/dd/yyyy to dd/MM/yyyy. when I choose an item and I click on my button, I use CDate(combobox1.text) because I will call a function that need a date parameter: Sub New(ByVal SchoolId As Integer, ByVal YearStartDate As Date)
the cdate return the string to MM/dd/yyyy, so YearStartDate will be in MM/dd/yyyy format. i
n the sub New, I will search the date in a database , I use a command:
Dim command As New OleDb.OleDbCommand( _
"SELECT tYears.* FROM tYears WHERE tYears.YearStartDate = #" & YearStartDate & "# AND tYears.SchoolId=" & SchoolId _
, cn)
in this command the date will be reformatted in MM/dd/yyyy so it was reversed....
example:
1-the date in the first database is 10/05/2005 with MM/dd/yyyy format as same as regional setting.
2-it will appear 05/10/2005 in the combobox because my culture have the dd/MM/yyyy format.
3-when I use CDate it makes it 10/05/2005
4-when I use the Select command the string make it 05/10/2005, so I will search 05/10/2005 that will be never found!!!!!!!!!!!!!!!!!!
what is the solution?????????????????????//
thanks
OmarMallat
|
|
|
|
|
May I found the solution, but how can I get and set the regional setting date format from my application????
OmarMallat
|
|
|
|
|
You can get the current regional setting's date format via...
Application.CurrentCulture.DateTimeFormat.ShortDatePattern
Setting the date format is another matter. The above property is read-only, so the only way to change the date format just for your application is to overwrite your app's current CultureInfo.
Dim info As System.Globalization.CultureInfo<br />
info = System.Globalization.CultureInfo.CurrentCulture<br />
info = New System.Globalization.CultureInfo(info.LCID, True)<br />
info.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"<br />
System.Threading.Thread.CurrentThread.CurrentCulture = info
|
|
|
|
|
I know how to change a culture and read the date format for a culture, but I want to read the and set the date format of the windows, like if I go to Regional and languages control and change it...
Don't worry and thank you very much, but can you help me. I think that I can do a same thing using API (GetLocalInfo, SetLocalInfo), but still searching....
OmarMallat
|
|
|
|