|
Sure. You can use the System.Environment class to get the command line arguments in a String array. Something like this should work for you:
Dim arguments As [String]() = System.Environment.GetCommandLineArgs()
The System.Environment class will also let you get the entire command line as a String, get at environment variables, get and set the exit code of your app, current directory, NETBIOS machine name, ...
Docs on the class can be found here[^] on MSDN.
RageInTheMachine9532
|
|
|
|
|
|
I want to create a TextBox Control that will change the back colour when it gets focus and then reset the back colour when it leaves focus
|
|
|
|
|
Use the GotFocus() and LostFocus() methods of the TextBox control to change the background color.
...
Private Sub TextBox1_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox1.GotFocus
TextBox1.BackColor = System.Drawing.Color.Blue
End Sub
Private Sub TextBox1_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox1.LostFocus
TextBox1.BackColor = System.Drawing.Color.White
End Sub
...
|
|
|
|
|
If you want this functionality in a custom control here are the steps you need to follow: (from the documentation on Inheriting from Existing Windows Form Controls)
1) Create a Windows Executable or a Windows Control Library project. (in the end you'll want to use a Windows Control Library, but for my test I just created the control in a Windows Executable project)
2) From the project menu select Add Inherited Control.
3) Select Custom Control in the Add New Item dialog box.
4) Go into the code for your new control and modify it so that you are inheriting from the specific control (in our case TextBox).
change
Public Class MyColorTextBox<br />
Inherits System.Windows.Form.Control
to
Public Class MyColorTextBox<br />
Inherits System.Windows.Form.Textbox
...
Now put in your code for the GotFocus() and LostFocus() events...as we did before.
For my test I then put a TextBox control on the form of my test application. Then I went into the system generated code and changed the declaration of the Textbox to a MyColorTextBox.
ie.
change
Me.TextBox1 = New Systems.Windows.Forms.TextBox
to
Me.TextBox1 = New WindowsApplication1.ColorTextBox
Now what you really want to do is wrap your new control into a Windows Control Library so that you can just draw a MyColorTextBox on any form. But I'm not going to go into all of that here. Hopefully this is a good start for you.
|
|
|
|
|
My code is this :
---------------------BEGINS----------------------
Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
Dim Animals As Node
With TreeView1.Nodes
Set ndAnimals = .Add(, , , "Animals")
.Add ndAnimals, tvwChild, , "Dogs"
End With
---------------------ENDS----------------------
GOAL : To allow User to delete items such as "Dogs" from there system.
PROBLEMS : I dont understand what I need to do to make my code seek out
the files listed in the Tree
1) Dont know Operating Systems "drive letter" (where OS is installed)
2) Must create a backup if file is choosen from TreeView before deletion
|
|
|
|
|
I am new to ASP.NET and looking for help.
I am attempting to change the text on objects dropdowns, textbox, and so on.
I reviewed the information on executing string but I am having problems, below is the code and the error.
Could someone tell me what I am doing wrong.
Thank you.
Dim exeInstrt as string = "BUTN2.text = 'WORKS2'"
exeInstrt = Replace(exeInstrt,"'","''")
Execute(exeInstrt)
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30469: Reference to a non-shared member requires an object reference.
Source Error:
Line 19: Dim exeInstrt as string = "BUTN2.text = 'WORKS2'"
Line 20: exeInstrt = Replace(exeInstrt,"'","''")
Line 21: Execute(exeInstrt)
Line 22: ' Response.Write(exeInstrt & " ")
Line 23:
|
|
|
|
|
|
I need to do this dynamically it is for Languages in many ASP>NET pages and it is driven from a Data Base table.
Sorry for the lack of information
|
|
|
|
|
So you want to internationalize an ASP.NET application based on a database back end?
Why not just DataBind the Text property to a function that retrieves the text from your database? In your Page_Load, just call MyControl.DataBind()
eg:
<asp:Label id='MyControl' Text='<%# GetText('MyControl') %>'></asp:label>
and
Protected Function GetText(ControlName as String) as String
' I know what language the user wants, as I've
' probably stored it in the Session or something. Do whatever I need to
' do to get the text from the database or something. Then Return it.
End Function
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
This is good and we can use this elsewhere but all the Objects and all the Dim's that are messages and or error code messages are in this table for all languages of out applications. The code below is the code we will be using.
*****************************
sub bindLanguage()
Dim Strconn99 as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AAA MS Access\POS.mdb;"
Dim Conn99 as new OLEDBConnection(strconn99)
Dim Rdr99 as OLEDBDatareader
Dim Cmd99 as OLEDBCommand
Dim strSQL99 as string
STRSQL99 = "SELECT LANG FROM POS_USRPROFL " & _
" WHERE USERID = '" & UserID & "' "
Cmd99=New OLEDBCommand(strSQL99,Conn99)
Conn99.Open()
Rdr99 = Cmd99.executereader() 'A
while Rdr99.read <> false
LanguageID = rdr99(0)
end while
rdr99.close
conn99.close
if LanguageID = "" then
else
STRSQL99 = "SELECT OBJNM, TXTVAL " & _
" FROM POS_LANGUAGE " & _
" WHERE PAGENM = 'POS_View_Log_Language' " & _
" AND LANGCD = '" & LanguageID & "' "
Cmd99=New OLEDBCommand(strSQL99,Conn99)
Conn99.Open()
Rdr99 = Cmd99.executereader() 'B
while Rdr99.read <> false
Dim exeInstrt as string = Rdr99(0) & " = '" & Rdr99(1) & "'"
exeInstrt = Replace(exeInstrt,"'","''")
' Execute(exeInstrt)
end while
rdr99.close
conn99.close()
end if
end sub
***********************************
What we are looking for is a way to execute a string dynamically.
This is the code that is not working --> Execute(exeInstrt) <--.
We can see other uses for executing a string dynamically.
Do you know of anyway this can be done?
|
|
|
|
|
Junk the idea of executing code like that - it isn't practical. If you want to get all the language strings in one go, store the resultset in a DataTable instead of looping through a DataReader, and then just pull them out of that using the DataBinding mechanism I described earlier for controls, and a straight function call for anything else. You'll need an OLEDBDataAdapter to Fill the DataTable.
A colleague has suggested that you can use the Eval statement if you use JScript.NET as your code behind language, but neither of us recommend this approach, as it's intended for ASP application migration.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
OK Thank you for your time and I will look into this Thanks again.
|
|
|
|
|
|
I am developing a project in vb.NET and I am a beginner in this field. I required a code for simple chat server in which multiple clients can be connected (Please keep in mind that I am working on (file any where system). In this chat server the message should move btween client to client and client to the server. So please send me simple code.
Waqar Ahmad Nadeem
|
|
|
|
|
[Edit]
I just noticed that, according to your bio, you have a Masters Degree in Computer Science. So my original response, below, was probably pitched at the wrong level. I assumed you were new to programming, but with a Masters in CS you should have quite a bit of, at least, academic experiece.
[/Edit]
Why not start with a simpler project until you understand the environment you are working in. When I was a beginner programming in BASIC (Sinclair BASIC to be exact) I wrote simple programs like noughts-and-crosses and hangman.
Waqar Nadeem wrote:
I required a code for simple chat server in which multiple clients can be connected
This is quite a complex problem. Tracking mutliple clients is not something a beginner should be handling. Even I get dizzy with the thought of tracking multiple clients in a real time senario - That's what architectures like ASP.NET are good at. They help separate out the different clients so for the majority of the code I write it is like I have one user.
If you really must try to do this then break the problem in to smaller pieces. Then come back and ask questions on the smaller pieces. Questions like "I tried to do X but it didn't work and I got a Y error message. Here is the code I used, can anyone see where I went wrong?" are really good and will get a better response.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
Has anyone come accross a "Print All" icon? Where can I find one, as I would rather use an exiting icon rather then create one afresh.
|
|
|
|
|
|
can anyone figure out how to get this to work
btn(mstrfind).enabled = true
I need to figure out how i can call different buttons by inserting the names in the mstrfind since vb.net doesn't support controll arrays
Any help whould be greatly appreciated
[]D[][]\/[][]D
|
|
|
|
|
...shot in the dark, just add them to a collection:
dim mCollection as new collection
mCollection.add Button1, Button1.Name ' Add the object using its name as a key
mCollection.add Button2, Button2.Name ' Add another button
mCollection.item("Form1.Button1").Enabled = false ' Disable button1
See? I hope this is a clear enough example. You could get complex with a type safe collection which only accepts controls or you could maybe have a class which inherits from a control container and that might give you additional functionality, but this suggestion is low down dirty and should work.
Chris.
Nursey
|
|
|
|
|
Hi,
I have 4 individual windows controls in a single windows control lib. Is there a way I can assign a unique icon to each of them? Maybe I have to break them into separate projects.
Thanks.
Nursey
|
|
|
|
|
Put the ToolBoxBitmap attribute on each control class:
<ToolboxBitmap(GetType(MyControl), "MyControlBitmap.bmp")>
Include the bitmap you specified ("MyControlBitmap.bmp" in the above example) in the control's resource file, with the name you specified ("MyControlBitmap.bmp" here).
|
|
|
|
|
OK, I have 4 controls, 4 bitmaps all 16x16 using 16 color palette. Two of my controls display their toolbox bitmap and two display the old cog yellow cog wheel. What the heck is going on here.
Here is an example of one of my attributes.
I've rebuilt the assembly, unreferenced and rerefenced it, quit the IDE and gone back in, and everything I can think of.
<toolboxbitmap(gettype(ctlbutton), "ctlbutton.bmp")=""> _
Thanks.
Nursey
|
|
|
|
|
Hi, I'm really new to coding etc (have only had Visual Basic.Net for about two weeks now).
I'm trying to put together a little quiz programme for a friend of mine ( sort of combination of helping him out whilst giving myself something constructive to do to force me to learn the language).
Anyways, I've gotten to the point where I can transition between forms, have varied responses based on the questions the students give and have an output whereby I put their score and some other details ( name, dob correct answers to the questions they got wrong etc) into a text file.
So far all of that works just fine. My problem is that I want the text file to be printed. It is just a simple file called "script.txt" in the bin folder. Anyways, I have two books which purport to teach one how to learn Visual Basic but NEITHER of them actually gives an example of "How to cause a given text file to be printed when a user presses button x."
Could anyone help me out?
I'm currently looking at some sort of horrible workaround where I try to get the .txt file to FileStream into a RichTextBox and then print the text content of the RichTextBox but I know there must be some other way.
ANY help would be hugely appreciated. I've spent a day banging my head against this particular wall and I'd like to learn the answer for next time.
|
|
|
|
|
Fionn wrote:
I'm currently looking at some sort of horrible workaround where I try to get the .txt file to FileStream into a RichTextBox and then print the text content of the RichTextBox but I know there must be some other way.
If it works!?!
You could always transfer it to notepad:
notepad /p c:\myfile.txt
But that's a bit horrible because the notepad window opens as it is printing. Then closes down again.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|