Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,209,519 members, 8,006,311 topics. Date: Monday, 18 November 2024 at 09:25 PM

Visual Basic Help Pls. Other Languages Can Try Too - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Visual Basic Help Pls. Other Languages Can Try Too (1878 Views)

Help Me Write The Quadratic Equation (almighty Formula) In This Languages / Translate Automatically Some Pages From English To Other Languages Like German / PHP Editor: also supports other languages (2) (3) (4)

(1) (Reply) (Go Down)

Visual Basic Help Pls. Other Languages Can Try Too by VURN(m): 9:20pm On Oct 27, 2011
Please write an example or a sample vb code to have two nested loops and a select case statement. Like this

do

do

select case

end select

loop

loop

i'll be glad to get your help as i need it urgently. You can use any example to do it. Also, use any condition such as while or until. Thanks for your assistance
Re: Visual Basic Help Pls. Other Languages Can Try Too by HumbleP: 10:43pm On Oct 27, 2011
please, specify which VB edition.
Re: Visual Basic Help Pls. Other Languages Can Try Too by VURN(m): 10:54pm On Oct 27, 2011
any edition of vb. Vb6 or vb.net. Thanks 4 ur concern
Re: Visual Basic Help Pls. Other Languages Can Try Too by HumbleP: 11:05pm On Oct 27, 2011
Now i am concerned as to why you are giving any option for the solution.
What exactly is the problem meant for?
Sorry, but i tot u had like a very seriois project you were working on and it was in a particular edition of VB.
But now, I do not see how any given solution would help particularly, seeing that the syntax are a tad bit different.
Re: Visual Basic Help Pls. Other Languages Can Try Too by VURN(m): 11:11pm On Oct 27, 2011
Its an assignment we're submitting soon. I don't want to restrict it to vb.net so that i'll get reply quick from any one that can try even if it is another language. I 'll know how to rewrite it in vb.net. Thank you
Re: Visual Basic Help Pls. Other Languages Can Try Too by Kobojunkie: 12:42am On Oct 28, 2011
@Poster, why don't you read up on loops? I mean I don't see why this would be hard for anyone. In most every text out there, the section on conditionals is usually not more than 2 pages long. So what exactly are you having issues with? Even the internet is LITTERED with examples of nested loops, so I want to believe you are not here asking us how to write nested loops and maybe there is more to this.
Re: Visual Basic Help Pls. Other Languages Can Try Too by VURN(m): 9:51am On Oct 28, 2011
I'm not really good at imagination. I've been thinking of what situation or real life example i can use 2 nested loops with select case inside the inner loop. I've tried somethin like this:

dim yr as integer
yr=0
do while yr <5
do
select case yr
case 1
debug.print "one"
case 2
debug.print "two"
end select
yr=yr+1
loop
loop

i've come up with this but i don't know if its correct and i would love it to be a real life situation like studen's grade in a department and faculty or shelves in a super market or any thing you can think of. Please help me before it gets late. I'd so much appreciate.
Re: Visual Basic Help Pls. Other Languages Can Try Too by Kobojunkie: 6:36pm On Oct 28, 2011
Example application : While walking from one store to another when you are at the market

do while walking from store to store in the market place

do while checking the shelves in each store

select case (if item found)
    case Vaseline:
make sure the price is no more than Naira 200
if(yes)
      buy_Vaseline
break;
  case Panadol:
Check Expiration date
If (Not expired)
    price it and buy
  case ShelfEmpty
break//move to the next shelf
case dont Like the store
Exit // go to the next store
End Select

                 loop
loop
Re: Visual Basic Help Pls. Other Languages Can Try Too by VURN(m): 7:51pm On Oct 28, 2011
@kobojun
i'm so much gratefull for your assistance. I now really understand when to use them. But please, could you make the code something to run let me type code it and debugg so i'll see how it'll run. Could you also use level and grading like 100 level, 200 level as in the university situation. Thanks so much
Re: Visual Basic Help Pls. Other Languages Can Try Too by Kobojunkie: 10:23pm On Oct 28, 2011
OR you can type it out yourself, try to run it. And if you are still unable to do it, you can post the code and we help you debug it. I mean most IDEs provide you sufficient messages these days to help you figure out what the problem in your code is. Google also offers you a lot of examples for you to learn from. Not entirely sure what more you need.
Re: Visual Basic Help Pls. Other Languages Can Try Too by Nobody: 12:18am On Oct 29, 2011
@kobojunkie, i knew i will see you here. Anywhere visualbasic comes up.
I don take all my vb chop javascript finish.
Re: Visual Basic Help Pls. Other Languages Can Try Too by Kobojunkie: 3:56am On Oct 29, 2011
^^^ I have no clue what in the world you are talking of there.
Re: Visual Basic Help Pls. Other Languages Can Try Too by dellnet: 2:12pm On Oct 29, 2011
For the sake of simplicity lets take a department with 5 students and 5 subject, I will use the code below to generate the subjects and scores
 Dim sm As New Random(TimeOfDay.Millisecond)

Dim subjects As String() = {"CS101", "CS114", "PY110", "MH160", "SS101"}
Dim students()()() As String = New String(4)()() {} 'jagged array
For i As Integer = 0 To 4
students(i) = New String(2)() {}
students(i)(0) = subjects
Dim numbers(4) As String
For G As Integer = 0 To 4 'randomly generate some grades
numbers(G) = sm.Next(5, 99).ToString()
Next
students(i)(1) = numbers
Next


Having our data ready lets test the control structure
        Dim student As Integer, marks As Integer, grade As Integer
student = 0
Do While student < 5
marks = 0
Debug.Print("Student Number: " & student)
Do While marks < 5
grade = students(student)(1)(marks)
Select Case grade
Case Is < 35
Debug.Print(" Subject: " & students(student)(0)(marks) & " FAIL"wink

Case Else

Debug.Print(" Subject: " & students(student)(0)(marks) & " PASS"wink
End Select
marks += 1
Loop
student += 1
Debug.Print(""wink
Loop

I just did this so you can have a code to tweak. I have not really checked if the logic is correct.
Re: Visual Basic Help Pls. Other Languages Can Try Too by VURN(m): 8:05pm On Oct 30, 2011
@dell net
you have saved me. You have answered my question.
@kobojun
thank you so much for your time and attention.

I would be glad if i can get more examples please. My thumbs are up for you guys. I thank God for nairaland. Please i'm expecting more
Re: Visual Basic Help Pls. Other Languages Can Try Too by 9ja4eva: 6:57pm On Mar 03, 2012
Can anyone help me make sense of this :

Public Event CheckedChanged (sender As Object, e As System.EventArgs) is an event, and cannot be called directly. Use a 'RaiseEvent' statement tp raise an event?



Me.radioButtonCommission.CheckedChanged += New System.EventHandler(AddressOf Me.radioButtonCommission_CheckedChanged)
'
Re: Visual Basic Help Pls. Other Languages Can Try Too by dellnet: 8:45pm On Mar 03, 2012
You listen to events. So if you want to know when your radio button is checked you should put the event in your code and map it to radio button.

I am guessing you want to listen to your radiobutton,,,use something like this
Public Sub CheckedChanged (sender As Object, e As System.EventArgs) Handles radioButtonCommission.CheckChanged
'do your damage here
End sub
Re: Visual Basic Help Pls. Other Languages Can Try Too by Kobojunkie: 11:57pm On Mar 03, 2012
9ja4eva:

Can anyone help me make sense of this :

Public Event CheckedChanged (sender As Object, e As System.EventArgs) is an event, and cannot be called directly. Use a 'RaiseEvent' statement tp raise an event?

Me.radioButtonCommission.CheckedChanged += New System.EventHandler(AddressOf Me.radioButtonCommission_CheckedChanged)

Simple do this

[size=13pt]Public Event CheckedChanged (sender As Object, e As System.EventArgs)  Handles radioButtonCommission.CheckedChanged
[/size]

What the above means is that you have a RadioButton somewhere on your form/page with ID="radionButtonCommission". Since it is a RadioButton instance(and I am assuming you are using the RadioButton control from the ASP.NET toolbox. If windows client, this also applies), whenever radiobuttonCommission is checked by the user or anyone, an event is raised notifying the code that it has been Checked. Now specifying the method above(the method in colour), tells the .NET process that this is the method in charge of handling all CheckedChanged events from this particular RadioButton i.e radioButtonCommission.
Re: Visual Basic Help Pls. Other Languages Can Try Too by 9ja4eva: 5:38am On Mar 04, 2012
Oh i was able to solve it. Thanks Kobo

However, e get this problem wey no wan go, any ideas?

VB 2010

Type 'var' is not defined


Code :

Dim salesRepSalescollection


                    Dim list As New List(Of SalesRepSales)()
                    For Each item As var In salesRepSalescollection
                        Dim netProfit As Decimal = Calculations.getNetProfit(result.Where(Function(e) e.SalesRepID = item.Key).LastOrDefault().AcquisitionCost, result.Where(Function(e) e.SalesRepID = item.Key).LastOrDefault().SellingPrice, result.Where(Function(e) e.SalesRepID = item.Key).LastOrDefault().MaintenanceCost)
                        Dim commision As Decimal = netProfit * CDec(0.3)

                        If commision < 100 Then
                            commision = 100
                        End If

                        list.Add(New SalesRepSales() With { _
                         .TotalSales = result.Where(Function(e) e.SalesRepID = item.Key).Sum(Function(pkg) pkg.SellingPrice), _
                         .Name = result.Where(Function(e) e.SalesRepID = item.Key).LastOrDefault().Name, _
                         .Commission = commision, _
                         .PhotoFile = result.Where(Function(e) e.SalesRepID = item.Key).LastOrDefault().PhotoFile, _
                         .SalesRepID = result.Where(Function(e) e.SalesRepID = item.Key).LastOrDefault().SalesRepID, _
                         .VehicleSold = result.Where(Function(e) e.SalesRepID = item.Key).Count() _
                        })
                    Next

                    dataGridViewGroup.DataSource = list.ToList()

                    SetSalesGroupFormatting()
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
End Try

End Sub
Re: Visual Basic Help Pls. Other Languages Can Try Too by Kobojunkie: 5:27pm On Mar 04, 2012
^^^The 'var' keyword applies to C# and not VB/NET. Your code there is VB.NET.

here is a post on possible ways around it http://stackoverflow.com/questions/2478552/vb-net-equivalent-to-c-sharp-var-keyword

(1) (Reply)

I Built An App To Watch Live Free Tv Called Intenu / How To Build A One-on-one Chat Im With Phpsockets.io / The 9 Most Demanded Programming Languages Of 2016

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 43
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.