gpt4 book ai didi

vb.net - VB 2010随机播放wav文件Windows 8 RP

转载 作者:行者123 更新时间:2023-12-02 22:41:53 24 4
gpt4 key购买 nike

我需要5个wav文件才能在程序结尾随机播放。我知道如何播放一首歌,而且我已经在该站点上找到了一个代码,但是它对我不起作用,每次都播放同一首歌。这是代码:

    Public Sub PlayRandomTrack()


Dim trackNum As Integer = CInt(Rnd() * 5 + 0.5)

Select Case trackNum
Case 1
My.Computer.Audio.Play(My.Resources.CallingMonsters, AudioPlayMode.Background)
Case 2
My.Computer.Audio.Play(My.Resources.McclainSisters, AudioPlayMode.Background)
Case 3
My.Computer.Audio.Play(My.Resources.Mendler, AudioPlayMode.Background)
Case 4
My.Computer.Audio.Play(My.Resources.Pray, AudioPlayMode.Background)
Case Else
My.Computer.Audio.Play(My.Resources.WillowWhip, AudioPlayMode.Background)

End Select
End Sub

然后将其用作:
    PlayRandomTrack()

我究竟做错了什么?

最佳答案

MSDN:

For any given initial seed, the same number sequence is generated because each successive call to the Rnd function uses the previously generated number as a seed for the next number in the sequence.

Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer.

关于vb.net - VB 2010随机播放wav文件Windows 8 RP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13363452/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com