|
Normall in appSettings the values you can access through
System.Configuration.ConfigurationManager.AppSettings
Are set like this:
<applicationSettings>
<add key="MCMSCefasMailServerName" value="LOWEXPRESS"/>
<add key="MCMSCefasMailBoxName" value="MCMS_OLC_Cefas"
...
That is how you get values into your appsettings.
When you use the settings parameters you have created a new config section so you would handle that differently. I would suggest you manually change the entries to match my example above and it should work fine.
Hope that helps.
Ben
|
|
|
|
|
Hi Ben,
yes that is a big help - thank you very much.
Kind regards,
Polly
|
|
|
|
|
Im looking for a way to write a tag to a jpeg file in Vista
I have a lot of existing jpeg files and I would like to be able to set the tag for them from within my program
Anybody have an example or any reference they can point me to
Thanks
|
|
|
|
|
Hey guys, I have a bit of code that's giving me trouble. I have an If Then statement within a timer which checks if the user has pressed a certain key. If so, it should display a messagebox, but every time the timer ticks, it displays the messagebox regardless of any buttons being pressed. Here's the code:
Private Sub UpTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpTimer.Tick<br />
<br />
If Keys.Up Then<br />
MessageBox.Show("", "")<br />
End If<br />
<br />
End Sub
Thanks!
|
|
|
|
|
This is because you're code is checking the value of the enumeration Keys.Up against 0, which will always return true since there is no key with a scancode of 0.
Your code won't work. As there is nothing that holds the value of the last key pressed. You don't need a Timer for this. All you need to do is handle the form's KeyDown event.
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Up Then
MessageBox.Show("", "")
End If
End Sub
Oh...I almost forgot. In order for the Form's Key events to work, you have to enable it's KeyPreview property. This gives the form the first look at the keys being hit, instead of the keys being sent directly to the controls on the form.
Me.KeyPreview = True
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Yes, I know that you can do that, but I only want this to occur when the timer is on. Once the timer turns off I want the key to do something else. I also have other things within the timer, I just showed you the problem area. The other things in the code don't affect the outcome if this.
If I wanted to do this within my timer, how would I do that?
|
|
|
|
|
Exactly the same thing, but, in the KeyDown event, you'd save the KeyCode off to a class-scoped variable that you check in your If statement in the Timer Tick event.
Public Class MyForm
Private LastKey As Keys
Keydown Handler
LastKey = e.KeyCode
Tick Handler
If LastKey = Keys.Up Then
...
End If
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
I like to be a .NET purist, meaning that if I know something is a VB6 specific function I want to try to avoid it. In doing so there are times that the work around becomes a hassle as is the case with Format(). Say I have a string strValue = "0001" and I want to add some characters around it and within it. If I were to say use Format(strValue, "**000/0**) I believe I would end up with "**000/1**" . What is the equivalent of that with .NET without concatenating strings? String.Format() gives a different output.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
CleaKO wrote: strValue = "0001"
CleaKO wrote: Format(strValue, "**000/0**)
The old string formatting characters in VB6, I think the whole set was "@&<>!", are no longer supported in VB.NET. They've been supplanted with something like this:
Debug.Print(String.Format("**000{0,8}0**", "ABC123"))
Results:
**000 ABC1230**
Or, for a left-justified field:
Debug.Print(String.Format("**000{0,-8}0**", "ABC123"))
Results:
**000ABC123 0**
The 8 and -8 just say that this field, whatever ends up in it, must be 8 characters wide and should be padded with spaces. The 0 means that this is the placeholder for the first expression argument.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Not sure, what you are trying to accomplish, but if you use the numeric value of strValue, it would be something like that:
string s = "0001";
s = string.Format("**{0:000/0}**", Convert.ToInt32(s));
Sorry that's c#, assume similar syntax for VB.
Hope that helps.
|
|
|
|
|
I build a treeview from data sorted alpha. Everything works fine, looks fine.
However treeview.topnode.ensurevisible() is at about the 4 th node.
Treeview.Nodes(0).Ensurevisible() works!
Does anyone know what property VB uses to determine the top node?
|
|
|
|
|
It sounds like you've assumed that TopNode returns the root node of the Tree. Reading the documentation tells you what is really means. TopNode returns the first fully-visible node displayed in the TreeView.
And it's not VB that makes this determination, it's the code in the TreeView code in the .NET Framework.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Silly me, I assumed the top node was the Top Node! Thanks for the clarification.
|
|
|
|
|
I am using CodeDom to write some code.
e.g. To create a class:-
<br />
Dim _generator As System.CodeDom.Compiler.ICodeGenerator<br />
Dim _writer As System.IO.TextWriter<br />
Dim _codeGenOptions As System.CodeDom.Compiler.CodeGeneratorOptions<br />
<br />
'Set the desired language to vb<br />
Dim foo As New Microsoft.VisualBasic.VBCodeProvider<br />
_generator = foo.CreateGenerator("C:\duncan.vb")<br />
<br />
<br />
'Set the code generation options to be used when creating this class<br />
_codeGenOptions = New System.CodeDom.Compiler.CodeGeneratorOptions<br />
_codeGenOptions.BlankLinesBetweenMembers = True<br />
_codeGenOptions.VerbatimOrder = False<br />
<br />
If Not _generator Is Nothing Then<br />
_writer = New System.IO.StreamWriter(fi.FullName)<br />
<br />
Dim _myDocumentClass As New CodeTypeDeclaration("DuncansClass")<br />
_myDocumentClass.Attributes = MemberAttributes.Public<br />
_myDocumentClass.Comments.Add(New CodeCommentStatement(" Created " & System.DateTime.Now.ToString))<br />
<br />
Dim _txtmember As New CodeMemberField<br />
_txtmember.Type = New CodeTypeReference("System.String")<br />
_txtmember.Attributes = MemberAttributes.Private<br />
_txtmember.Name = _generator.CreateValidIdentifier("_Duncan_Text")<br />
_txtmember.Comments.Add(New CodeCommentStatement("Text to use here "))<br />
_myDocumentClass.Members.Add(_txtmember)<br />
<br />
End If<br />
<br />
_generator.GenerateCodeFromType(_myDocumentClass, _writer, _codeGenOptions)<br />
which creates the code:
<br />
'Created 2007-04-21<br />
Public Class DuncansClass<br />
<br />
'Text to use here<br />
Private _Duncan_text As String<br />
<br />
End Class<br />
Any Ideas as to how I could put the private member declaration in a region using codeDom?
e.g.
<br />
'Created 2007-04-21<br />
Public Class DuncansClass<br />
<br />
#Region "Private members"<br />
'Text to use here<br />
Private _Duncan_text As String<br />
#End Region<br />
<br />
End Class<br />
|
|
|
|
|
Could you be looking for the CodeRegionDirective[^] class? Be careful, not all languages support Regions!
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Excellent - that did the trick, thanks...
|
|
|
|
|
Any time!
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi all,
I have a case where i bounded data to a list box in a windows application and i want to place a button in that form so that i can move the items up or down. Moreover i want to maintain that order when i leave the form and enter it again.
Thanks
|
|
|
|
|
Guys i managed to move the listbox items up and down but i need to maintain that new state. How can i?
|
|
|
|
|
What will the coding for eject and load CD\DVD ROM???
|
|
|
|
|
You will probably not find someone who will just give you the code. Try searching or writing your own, then when you have a specific question/problem repost the question with the specific problem.
__________________
Bob is my homeboy.
|
|
|
|
|
Google results for "vb.net eject cd[^]".
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
|
i downloaded some examples, all were in C sharp and working good but when i convert the codes to vb.net, then its giving two errors
Error 1 'Shared' is not valid on a Declare.<br />
Error 2 'System.Runtime.InteropServices.DllImportAttribute' cannot be applied to a Declare.
errors are in following code
<DllImport("winmm.dll", EntryPoint:="mciSendStringA")> _<br />
Public Shared Declare Sub mciSendStringA Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long)
someone know why this is happening???
|
|
|
|
|
You don't need the Shared modifier, get rid of it. You also don't need the DLLImport attribute. It's specific to C# code. And those Long's should be Integer's. This tell's me that you converted VB6 AND C# code to VB.NET. The Declare should look like this:
Private Declare Function mciSendStringA Lib "winmm.dll" ( _
ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uBufferLength As Integer, ByVal hwndCallback As IntPtr) As Integer
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|