|
This is how we have been taught to write programs. I have no idea about console applications. The teacher has never mentioned it.
|
|
|
|
|
new_rez wrote: This is how we have been taught to write programs. I have no idea about console applications. The teacher has never mentioned it.
Really? If that is the case the state of your course is terrible. You should be writing simple console applications to learn about simple stuff like arrays. Learning about an event driven paradigm first is a bit crazy because you lose the sense of the flow of control of your program becuase you are placing that in the hands of the user.
|
|
|
|
|
Yeah, I despair at the people who self teach in this manner ( I've had people told me 'I wrote hello world, I don't need to write console apps', his posted sample code told a different story ), but for a course to teach like this is inexcusable.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
OK, your teacher IS an idiot. You don't need a GUI for this app, and having to write GUI code will just distract you from the exercise at hand.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Like Colin said : why use forms ?
new_rez wrote: InputBox
Don't do this, it's VB6 rubbish. Don't use forms at all, but when you do, don't use stuff hanging over from VB6. The easy way to avoid it - never use the visual basic namespace.
new_rez wrote: Dim intNumbers(19) As integer 'array with 10 elements
This array plainly has 19 elements, not 10.
new_rez wrote: For intCount = 1 To 10
lstNumbers.Items.Add(intNumbers(intCount - 1))
Next
why not start your loop at 0, instead of doing -1 every time ?
new_rez wrote: Dim dblTotal As Double
Dim dblAverage As Double
'total
For intCount = 0 To 9
dblTotal = dblTotal + intNumbers(intCount)
Next
'average
dblAverage = dblTotal / 10
You're on the right track, here. I need to post this, so I can refer back to the question, it's the negative values you have trouble with ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
If it's so urgent, why are you not replying ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: If it's so urgent, why are you not replying ?
Good question!
|
|
|
|
|
new_rez wrote: I have had a try and ive managed to build the array, but, it is rubbish and doesn't work very well.
Then show us your code so far, and we can guide you on how to continue. But, as Christian said it is a very trivial problem and to explain it to you would be to do it for you. You wouldn't learn anything if we did that. It might be great for my job security and salary negotiations, but I'd rather you were able to do your job properly.
|
|
|
|
|
how to remove a string like '............344' from the text
here is the sample text:
'1. visual basic.net ............344'
so the result would be like this:
'1. visual basic.net'
i am using regular expression in vb.net
this is the sample code
sText = Regex.Replace(sText, " (\\.+)\\d+", "");
thanx
|
|
|
|
|
That looks fine to me. Did you test it in Expresso ? You don't actually ask a question, I presume there's a problem with this code ? What is the problem ?
If the string is always exactly the same, just use string.Replace.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
It took a week for you to say 'it doesn't work' ? Did you download Expresso ? What does it do ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I just can't access the information in the AppSettings part of my appConfig file.
I have used the following statements -
1/ strKeys = ConfigurationManager.AppSettings.AllKeys
and strKeys.Count = 0
2/ ConfigurationManager.AppSettings.Count
this equals 0 too
3/ ConfigurationManager.AppSettings("theName")
this returns 'nothing'
The appConfig file has been created through the Settings of the IDE and compiles just fine.
Please can anyone help. I would be very grateful.
Many thanks,
Polly Anna
|
|
|
|
|
Without seeing your App.Config file (make sure you enable the "Ignore HTML tags in this message" checkbox before you post it!), it's impossible to tell you why it failed. The App.Config is nothing but an XML text file that is NOT compiled into your app. Therefore, you won't get any error message if it's not formatting properly.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
When you make changes to your app.config file you need to build your app and then your exename.exe.config file gets created.
So I am guessing that either you changed your app.config file and didn't recompile. Or you changed your exename.exe.config file and then built your app and it got wiped out.
Note you don't get an app.config file by default. If you add one to the project you still have to add the appSetting section.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
Hope that helps.
Ben
|
|
|
|
|
Hi Ben, Hi Dave,
Thank you for your responses.
I have used the VS2005 Express Edition IDE, Project > Properties > Settings to specify the Application Settings part of the config file.
I have put a copy of the original appconfig file below.
After what you said about what my config file should look like, I removed the following enclosing tags
<applicationSettings>
<EmailProcessor.My.MySettings>
bla bla bla settings
</EmailProcessor.My.MySettings>
</applicationSettings>
and replaced them with these -
<appSettings>
bla bla bla settings
</appSettings>
but it still did not work.
My VB.Net code that tries to access the information in the AppConfig file is as follows -
A/ i = System.Configuration.ConfigurationManager.AppSettings.Count
This outputs zero
B/ strMailServerName = ConfigurationManager.AppSettings("PW03MailServer")
This outputs nothing
C/ strMailServerName = My.Settings.PW03MailServer
This outputs the correct information - but I cannot use it as I
want to allow many subscribers to use this program.
Thank you very much for your thoughts to date. I would be very pleased if you could help me find out why this isn't working.
Kind regards,
Polly Anna
A/ Original config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="EmailProcessor.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="EmailProcessor.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<applicationSettings>
<EmailProcessor.My.MySettings>
<setting name="MCMSCefasMailServerName" serializeAs="String">
<value>LOWEXPRESS</value>
</setting>
<setting name="MCMSCefasMailBoxName" serializeAs="String">
<value>MCMS_OLC_Cefas</value>
</setting>
<setting name="MCMSCefasMailBoxPassword" serializeAs="String">
<value>password</value>
</setting>
<setting name="MCMSCefasAttachmentType" serializeAs="String">
<value>xml</value>
</setting>
<setting name="MCMSCefasFolder" serializeAs="String">
<value>C:\Folder</value>
</setting>
<setting name="PW03MailServer" serializeAs="String">
<value>LOWEXPRESS</value>
</setting>
<setting name="PW03MailBoxName" serializeAs="String">
<value>PW03</value>
</setting>
<setting name="PW03MailBoxPassword" serializeAs="String">
<value>daniel1132</value>
</setting>
<setting name="PW03AttachmentType" serializeAs="String">
<value>xml</value>
</setting>
<setting name="PW03Folder" serializeAs="String">
<value>C:\Polly'sFolder</value>
</setting>
<setting name="PW03LogFile" serializeAs="String">
<value>C:\Polly'sFolder</value>
</setting>
<setting name="MCMSCefasLogFile" serializeAs="String">
<value>C:\Folder</value>
</setting>
</EmailProcessor.My.MySettings>
</applicationSettings>
</configuration>
|
|
|
|
|
I've found out what the problem was.
I was using a windows form in another project (i.e. Solution had 2 projects), so it was reading the appConfig file of the windows form and not of the Class library.
Really sorry to have wasted everybody's time - including my own and thank you very much for your suggestions which I have used - i.e. I have used <appsettings> as opposed to <applicationsettings>
Thank you once again.
Kind regards,
Polly Anna
|
|
|
|
|
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)
|
|
|
|