Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2009, 01:52 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hmmm. It doesn't look like you set the Text property of your label anywhere. Try this code:

vb Code:
Dim Mark As Integer
If Integer.TryParse(TextBox1.Text, Mark) Then
     If Mark >= 80 then label1.Text = "A"
     ElseIf Mark >= 60 AND Mark < 80 then label1.Text = "B"
     ElseIf Mark >= 40 AND Mark < 60 then label1.Text = "C"
     Else label1.Text = "D"
     End If
Else
    label1.Text = "Please enter a numeric value into the Text Box!"
End If

Replace labe1 with whatever the label in your app is called.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old April 6th, 2009, 02:18 PM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes this is my first time programming and i am finding it hard to grasp the logic. no worries cheers for the help anyway
 
Old April 6th, 2009, 02:25 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Did the code that I posted help or....?

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old April 6th, 2009, 02:56 PM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry doug, had clicked to reply before i had seen your reply. will have a look now and let you know how i get on. thanks alot for your patience and help!
 
Old April 6th, 2009, 04:33 PM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Almost got there now!

Apart form it says End of statement expected after label1.Text = "B" and abel1.Text = "C". It works if i delete those 2 and if it is over 80 then a comes up but that is all i can do.

Ah well cheers anyway i might as well give up I am obviously not up to learning this, I think i might have to learn vba instead anyway.

Thanks for all your help though it is much appreciated
 
Old April 6th, 2009, 04:49 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

"Give up"? To quote Darth Vader "I find your lack of faith disturbing". ;]

Here is the deal, programming is not easy if it were easy EVERYONE would do it. In the beginning there is plenty of trial and error and there are going to be times you simply want to throw your box out the window. Believe me, I was there. But what is giving up really going to net you? Nothing. Moving onto VBA is also of little good since the same fundamentals (mostly) that apply to VB.NET apply to VBA as well as every other programming language (And before someone goes off and says XYZ is completely different in FORTRAN as compared to VB.NET I am talking about the logic involed and so forth).

The code that I posted was a bit of an error on my part (I write code mostly off the cuff on here and sometimes it can be error prone). You should find that this code works:

vb Code:
If Mark >= 80 then
         label1.Text = "A"     
     ElseIf Mark >= 60 AND Mark < 80 then
         label1.Text = "B"     
     ElseIf Mark >= 40 AND Mark < 60 then
         label1.Text = "C"     
     Else
         label1.Text = "D"     
     End If

If you run into a problem, for example, the end of statement expected error do a google search for it. Chances are it will give you the answer faster then any of us can respond to it. Patience is truly a virtue here (in programming) otherwise you will drive yourself absolutely mad.

Finally, and I hate to say this, but if you keep up with the "quitters attitude" programming might not be for you. Very rarely is anything that is worth doing in life easy, programming is no different.

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old April 6th, 2009, 06:31 PM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Haha cheers for that, it works now!

I know programming is going to be hard and I am not actually going to give up, was just going to give up for tonight!

i didnt explain clearly, the reason why I am going to have to learn vba instead is because I have to do a project with excel. I need to create a programme that reads the data from a text file and inputs it into a spreadsheet on a loop so that when data is being added into the spreadsheet

Hi, I need to create an excel vba programme that will read data from a text file and contine to read the data even when the text file is open.

I am planning on creating a graph within the spreadsheet and then using another programme called max msp to input data into the file as i drag the mouse over the graph, and then get vba to poll on a loop so that as the data in the text file changes the data in the cells change and the graph changes accordingly.

I know it is going to drive me up the wall at times, i have learnt bits of max msp and that did my head in but that is an object based thing as opposed to code based so it is taking me a while to understand the logic.

Once again though thanks for being so patient and helping me!
 
Old April 6th, 2009, 06:39 PM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just gone back through it and it seems like it only works for numbers under 40 that come up with d and everythign else doesnt come up with anything.

It is almost midnight now and my head is hurting too much to try and figure it out now so will have another look tomorrow. Tried to google a few error statements i got and generally got confused at the context they were usually described in. cant believe that by just putting enter it fixed the end of expression statement though, shows how such tiny things can change everythign and how much attention to detail you need to have to do this!

Anyway once again thanks alot





Similar Threads
Thread Thread Starter Forum Replies Last Post
Flow chart of Cobol program in dotNet SOANS General .NET 0 November 20th, 2007 11:29 PM
Program Flow Interrupted By IF...THEN Statement squeege321 Pro VB 6 10 March 23rd, 2007 11:38 AM
Flow of the Program ? pandian Java Basics 2 March 20th, 2006 11:07 PM
weird program flow with nested loops zayasv Intro Programming 2 November 17th, 2005 06:19 AM
weird program flow with nested functions zayasv VB.NET 0 October 26th, 2005 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.