无法弄清楚如何显示正确的输出(包括代码)

时间:2016-09-23 01:28:11

标签: vb.net linq

我似乎无法弄清楚如何显示正确的输出。当我运行我的查询时,它应该说" eBook"为正确的格式。但是,我只能让它显示对应于" eBook"格式是1.我需要它来显示"电子书"而不是数字。这可能是一个非常简单的修复,但我是VB的新手,只需要另一组眼睛和帮助。

    Private Sub btnEBooks_Click(sender As Object, e As EventArgs) Handles btnEBooks.Click
    Dim Q = From book In books
            Let format = book.Format
            Let formatName = GetFormatName(book.Format)
            Where format = 1
            Order By book.Title
            Select book.Author, book.Format, book.Title, book.YearPublished

    dgvOutput.DataSource = Q.ToList
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
    Me.Close()

End Sub
Function GetFormatName(FNum As Integer) As String
    If FNum = 1 Then

        Return "eBook"
    End If
End Function

0 个答案:

没有答案