Help with Select Case

C

CSINVA

Can't seem to get this to work, maybe someone can put me in the
correct direction. I was thinking that "lng =
ddlWealth.SelectedItem.Text" would pass the item either "en" for
english or "es" for spanish and then return the movie back on the
screen "lblLang.Text = sMid", but all I get is the number 5.

Here is what the asp page looks like:

<asp:DropDownList ID="ddlWealth" runat="server" Width="78px">
<asp:ListItem Value="en">English</asp:ListItem>
<asp:ListItem Value="es">Espanol</asp:ListItem>
<asp:ListItem Value="de">Deutsch</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnGo" runat="server" Text="Go"
OnClick="buildurl" /><br />
<br />
<asp:Label ID="lblLang" runat="server" Width="153px"></
asp:Label><br />
<br />


Public Function Build_Movie(ByVal lng)

Dim iCase As String = lng
Dim movie As Integer = 5

Select Case iCase
Case "en"
movie = "55950"
Case "es"
movie = "55951"
End Select

Return movie

End Function

Protected Sub buildurl(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ddlWealth.TextChanged

Dim lng As String
lng = ddlWealth.SelectedItem.Text

Dim sMid As Integer
sMid = Build_Movie(lng)
lblLang.Text = sMid

End Sub
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

CSINVA said:
Can't seem to get this to work, maybe someone can put me in the
correct direction. I was thinking that "lng =
ddlWealth.SelectedItem.Text" would pass the item either "en" for
english or "es" for spanish and then return the movie back on the
screen "lblLang.Text = sMid", but all I get is the number 5.

Here is what the asp page looks like:

<asp:DropDownList ID="ddlWealth" runat="server" Width="78px">
<asp:ListItem Value="en">English</asp:ListItem>
<asp:ListItem Value="es">Espanol</asp:ListItem>
<asp:ListItem Value="de">Deutsch</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnGo" runat="server" Text="Go"
OnClick="buildurl" /><br />
<br />
<asp:Label ID="lblLang" runat="server" Width="153px"></
asp:Label><br />
<br />


Public Function Build_Movie(ByVal lng)

Dim iCase As String = lng
Dim movie As Integer = 5

Select Case iCase
Case "en"
movie = "55950"
Case "es"
movie = "55951"
End Select

Return movie

End Function

Protected Sub buildurl(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ddlWealth.TextChanged

Dim lng As String
lng = ddlWealth.SelectedItem.Text

Dim sMid As Integer
sMid = Build_Movie(lng)
lblLang.Text = sMid

End Sub

Use SelectedItem.Value instead of SelectedItem.Text.
 
H

Hans Kesting

CSINVA explained :
Public Function Build_Movie(ByVal lng)

Dim iCase As String = lng
Dim movie As Integer = 5

Select Case iCase
Case "en"
movie = "55950"
Case "es"
movie = "55951"
End Select

Return movie

End Function

First you define "movie" as Integer, but then you assign a string value
("55950")? Or is that a typo in the post?

I don't know much about vb.net, but shouldn't the function declare a
return type (Integer in this case)?

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top