基于VB的三菱PLC跟PC通信的(读取PLC的X寄存器状态)的例子

PLC是FX3u-48M的,小弟想做一个通讯的试验,我给PLC 的X0高电平后,想从VB上的程序读出X寄存器为高电平或低电平,Y寄存器的通断可以,但是要读X寄存器的状态该怎样设置?

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
通信返回的字符串对应的ASC码为21的内容
基于VB的三菱PLC FX3u-48M跟PC的串口通信,批量读取PLC的X000——X007的位状态时,PLC的X0为高电平,发送代码:sendata = Chr(5) + "00FFBR0X00000820" 第一次返回的是Asc码为6的字符,是应答信息,之后返回的为Asc码为21的字符, 代表的是什么呢?
三菱plc与上位vb编的界面间以太网通信
用vb的winsock编了个服务器,三菱plc做客户端,但一直连接不上,vb还需要装什么驱动软件吗,三菱plc用的是Q系列的,求指点
C# 西门子PLC S7 200通信
现在是西门子PLC那边有2个寄存器地址,是VB510,VB50,510是我的C#向里面写数据,但是怎么读取500发给我的数据,怎么解析(500给我的就是阿拉伯数字)
pc机与plc直接通信问题
我现在在用VB做一个软件,需要实现直接从西门子s7-300的PLC仿真软件中读取数据的功能,求大神指点我应该怎么做![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif)
vb 中如何访问plc地址中的值
在plc地址中M7500对应皮带,M7501对应输送机,M7502对应螺旋机,现在我要取到他们对应的值要如何做
vb.net通过Winsock 往PLC寄存器D写textbox里数值怎么写啊
1. Private Sub butWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butWrite.Click 1. Dim i As Short 1. Dim temp() As String 1. Dim WD() As Object 1. If Not EntLink Then 1. MsgBox("还未与PLC建立联接!") 1. Exit Sub 1. End If 1. ReDim WD(Val(txtWriteCnt.Text) - 1) 1. temp = Split(txtWrite.Text, vbCrLf) 1. For i = 0 To UBound(WD) Step 1 1. If i > UBound(temp) Then 1. WD(i) = 0 1. Else 1. WD(i) = Trim(temp(i)) 1. End If 1. Next i 1. ScanRet = PLC.CmdWrite(cmbWriteMry.SelectedIndex + 1, cmbWriteType.SelectedIndex + 1, Val(txtWriteAdd.Text), Val(txtWriteCnt.Text), WD) 1. txtReWrite.Text = ScanRet.ToString 1. End Sub 1.
VB 控制台达PLC Y0点的on off
strt = "0105" & "0500" & "FF00" strs = ":" & strt & LrcCheck(strt) & vbCrLf MSComm1.Output = strs 用VB发送 "0105" & "0500" & "FF00"指令,控制台达PLC的Y0点的on off,当PLC运行不能控制,但停止时却可以,这是怎么回事?求大神![图片说明](https://img-ask.csdn.net/upload/201901/03/1546475134_620341.jpg)![图片说明](https://img-ask.csdn.net/upload/201901/03/1546475140_361718.jpg)
多个控件状态的VB6.0语言中怎么实现判断数组的值被读取几次的功能?
多个控件状态的VB6.0语言中怎么实现判断数组的值被读取几次的功能?如何防止一个数组下标被重复读或者重复写?
基于vb设计pc与gsm模块串口通信,发收text格式短信
小白一个,花好几天都没搞出来,跪求各位大大帮忙设计一个程序,最好有解释的。要求可以收发删除text格式短信。。。![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/9.gif)![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/9.gif)![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/9.gif)![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/9.gif)
vb读取Excel表单里面的内容
用vb打开并读取Excel表单的内容 并且输出 有哪位大神帮忙解答一下
VS2015调用VB编写的动态链接库总报错
需要台达PLC与PC通信,下载了modbus的动态链接库,总是调用不成功,然后自己用VB编了一个简单的求最大值的动态链接库,用VB调可以成功,用VC总报错,求各位大神帮忙解答。报错如下:、 ![图片说明](https://img-ask.csdn.net/upload/201705/17/1494991070_265856.png)
基于VB.NET的opc程序AsyncWrite无法写入
在用VB.NET编写OPC读写西门子S7400程序一个地址,Asyncread能够顺利读取OPC SCOUT里面的数据,但Asyncwrite运行也无错误,但是却无法更改地址的数据, 在个人PC OPC SCOUT上,DB1.DBW数据无变化,AsyncWriteComplete无运行,请教高人我错在哪里或缺少什么?应该怎么改? Private Sub PLC_U_AddItem2() For j As Short = 65 To 65 MyOPCItemIDs2(j - 65) = "S7:[@LOCALSERVER]DB1,W1666,1" MyOPCItemIsArray2(j) = 0 MyClientHandles2(j) = j - 64 Next j MyGroup2.OPCItems.AddItems(ItemCount, MyOPCItemIDs2, MyClientHandles2, MyItemServerHandles2, AddItemServerErrors2) End Sub Sub PLC_AsyncRead() Dim MyErrors2 As System.Array If MyGroup2.OPCItems.Count > 0 Then lTransID_Rd2 = 1 MyGroup2.AsyncRead(1, MyItemServerHandles2, _ MyErrors2, lTransID_Rd2, lCancelID_Rd2) End If End Sub Private Sub PLC_AsyncWrite(ByVal NumItemsW As Integer, ByRef ItemValuesW As Array, ByRef MyErrors As System.Array) Dim lHandle As Array = Array.CreateInstance(GetType(Integer), 1) For i = 1 To 1 lHandle.SetValue(MyItemServerHandles2(i), i - 1) lTransID_Rd2 = 1 Next MyGroup2.AsyncWrite(1, lHandle, ItemValuesW, MyErrors, lTransID_Rd2, lCancelID_Rd2) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim ItemValuesW1 As Array = Array.CreateInstance(GetType(Object), dims, bounds) Dim myErrors As Array = Array.CreateInstance(GetType(Integer), dims, bounds) For i = 1 To 1 ItemValuesW1.SetValue(Convert.ToInt32(TextBox7.Text), 1) Next Call PLC_AsyncWrite(1, ItemValuesW1, myErrors) End Sub Private Sub MyGroup2_AsyncWriteComplete(ByVal TransactionID As Long, ByVal NumItems As Long, _ClientHandles() As Long, itemvalue() As Long, Errors() As Long) Dim i As Short MsgBox(1) For i = 0 To 32 buf(i) = itemvalue(i) Next End Sub End Class
vb.net 点窗体上的button,来执行键盘的键 Alt+a
如题,在vb.net上要怎么实现这个效果呢? vb.net 点窗体上的button,来执行键盘的键 Alt+a
【求助笔试题]】 找出VB.NET写的21点扑克牌程序中的问题
遇到一个面试题,题目要求是这样的 写了一个21点扑克牌的程序,用VB.NET写的,需要你找出其中的bugs,尽可能多 的找出,并写明错误原因 由于小弟写C#的,对VB.NET实在不熟悉,还希望有经验前辈帮忙看看 小弟不胜感觉 代码一共有6个类 分别是 Blackjack Card Deck Game Hand Player ProbabilityCalculator 代码文件如下 ``` ''' <summary> ''' Emulates a black jack game between two different AI players. 模拟两个不同的AI玩家之间的黑杰克游戏。 ''' </summary> Public Class Blackjack Public Shared ReadOnly AllCards As New List(Of Card) ''' <summary> ''' Static constructor. ''' Generates a list containing one of every possible card.生成一个包含所有可能卡片的列表 ''' This simplified game assumes a single deck of 52 cards, one of every unique suit and rank combination. ''' 这个简化的游戏假设有一副52张的牌,每副牌都有自己独特的花色和等级组合。 ''' </summary> Shared Sub New() For Each s As Card.Suit In [Enum].GetValues(GetType(Card.Suit)) For Each r As Card.Rank In [Enum].GetValues(GetType(Card.Rank)) AllCards.Add(New Card(r, s)) Next Next End Sub ''' <summary> ''' Main method. Constructs the object, plays the game, prints the output. ''' Don't change this method! ''' </summary> ''' <param name="args">Command line args, unused.</param> Public Shared Sub Main(args As String()) Dim deck As New Deck(AllCards) Dim random As New Random() Dim calculator As New ProbabilityCalculator(AllCards) Dim player1 As New Player("Harry", calculator) Dim player2 As New Player("Joe", calculator) Dim game As New Game(deck, random, player1, player2) Console.WriteLine(game.Play()) Console.ReadLine() End Sub End Class ``` Imports System Imports System.Collections.Generic Imports System.Text ''' <summary> ''' Represents a single playing card, the combination of a suit (Spades, hearts, clubs, diamonds) ''' and a rank (Ace, two, three... Jack, Queen, King). ''' 表示一张纸牌,是花色(黑桃、红心、梅花、方块)的组合 ''' 还有一排(a,二,三……杰克,王后,国王)。 ''' Any particular card is worth a number of points, according to its rank. ''' 任何一张特定的纸牌,根据它的等级,值若干点数。 ''' In this simplified game, an Ace is always worth 1 points. ''' A two is with 2 points, three worth 3, and so on. ''' The face cards (Jack, Queen, King) are worth 10 points. ''' 在这个简化的游戏中,a总是值1分 '''2是2分,3是3分,以此类推 '''脸牌(杰克、皇后、国王)值10分。 ''' </summary> Public Class Card Public Enum Suit Spades Hearts Clubs Diamonds End Enum Public Enum Rank Ace = 1 Two = 2 Three = 3 Four = 4 Five = 5 Seven = 7 Eight = 8 Nine = 9 Ten = 10 Jack = 11 Queen = 12 King = 13 End Enum ReadOnly mSuit As Suit ReadOnly mRank As Rank Public Sub New(r As Rank, s As Suit) mSuit = s mRank = r End Sub ''' <summary> ''' Returns a human readable name of the card, for example "Ace of Spades", suitable for inclusion in ''' the game's console output. ''' 返回人类可读的纸牌名称,例如“黑桃a”,适合包含在游戏控制台输出中 ''' </summary> ''' <returns>Name of the card</returns> Public ReadOnly Property Description As String Get ' Return mRank + " of" + mSuit Return mRank.ToString + " of" + mSuit.ToString End Get End Property ''' <summary> ''' Returns the number of points that this card is worth, according to its rank. ''' 返回该牌值多少分,根据其分值。 ''' </summary> ''' <returns>Point value of this card.</returns> Public ReadOnly Property Points As Integer Get Return CType(mRank, Integer) End Get End Property Public Overrides Function ToString() As String Return Description End Function End Class `` ''' <summary> ''' Represents a collection of playing cards that will be dealt in the game. ''' 表示将在游戏中处理的纸牌集合。 ''' A fresh deck usually begins with the cards in an ordered sequence according to their suit and rank. ''' 一副新牌通常是按照牌的花色和等级顺序排列的。 ''' Before dealing cards to the players, the dealer should shuffle the deck, <see cref="System.Random" /> ''' 发牌前,发牌人应洗牌 ''' otherwise cards will be dealt in their original sequence. ''' 否则,牌将按原来顺序处理 ''' During the game, the dealer deals one card at a time, removing it from the top ''' of the deck, and adding it to the player's hand. ''' 在游戏中,发牌人一次发一张牌,把它从牌顶移开 并将其添加到玩家手上。 ''' </summary> ''' <remarks></remarks> Public Class Deck ''' <summary> ''' The cards remaining to be dealt ''' 剩下要处理的牌集合 ''' </summary> Private mCards As List(Of Card) ''' <summary> ''' Constructs a fresh deck with the specified cards in the given sequence ''' 按照给定的顺序用指定的牌组构造新的牌组 ''' </summary> ''' <param name="cards">@param cards cards</param> Public Sub New(cards As List(Of Card)) mCards = cards End Sub ''' <summary> ''' Randomizes the sequence of the cards within the deck. ''' 将牌堆中的牌的顺序随机化 ''' </summary> Public Sub Shuffle(random As Random) ' Keep a reference to the existing cards, then build a new list and copy ' 保持对现有卡片的引用,然后建立一个新的列表并复制 ' the cards over in a random sequence. ' 这些卡片是随机排列的。 Dim originalCards As List(Of Card) = mCards Dim shuffledCards As New List(Of Card) Dim numberOfCards As Integer = originalCards.Count For i As Integer = 0 To numberOfCards Dim nextCardIndex As Integer = random.Next(originalCards.Count) Dim nextCard As Card = originalCards(nextCardIndex) shuffledCards.Add(nextCard) Next mCards = shuffledCards End Sub ''' <summary> ''' Draws a card from the top of the deck, so that it can be added to a player's hand. ''' 从牌堆顶部抽一张牌,这样它就可以加到玩家手上。 ''' </summary> ''' <returns>Dealt card</returns> Public Function Deal() As Card Return mCards(0) End Function ''' <summary> ''' Returns the list of cards in the deck, in the sequence that they are going to be dealt. ''' 返回牌堆中纸牌的列表,按将要处理它们的顺序排列。 ''' </summary> ''' <returns>Cards cards in the deck</returns> Public ReadOnly Property Cards As List(Of Card) Get Return mCards End Get End Property End Class ``` ''' <summary> ''' Controller responsible for overall game loop. ''' 负责整个游戏循环的控制器 ''' </summary> Public Class Game Private mDeck As Deck Private mRandom As Random Private mPlayer1 As Player Private mPlayer2 As Player Public Sub New(deck As Deck, random As Random, player1 As Player, player2 As Player) mDeck = deck mRandom = random mPlayer1 = player1 mPlayer2 = player2 End Sub Public ReadOnly Property Deck As Deck Get Return mDeck End Get End Property Public ReadOnly Property Random As Random Get Return mRandom End Get End Property Public ReadOnly Property Player1 As Player Get Return mPlayer1 End Get End Property Public ReadOnly Property Player2 As Player Get Return mPlayer2 End Get End Property ''' <summary> ''' Main control loop. You an imagine this routine to reflect the actions of the dealer, who ''' coordinates gameplay. ''' 主要控制回路。你可以想象这个程序反映了协调游戏玩法的商人的行动。 ''' This simple game is played by two players. ''' The dealer is given a single fresh deck of cards, which he then shuffles. ''' Each player is dealt two cards. ''' Then each player takes their turn. ''' During their turn, a player can choose to "hit", which means they want to be dealt another card, ''' or to "stand", which means they will end their turn. ''' The player may "hit" as many times as they wish before ending their turn. ''' Once both players have taken their turn, the winner is determined. ''' The winner is the player with the greatest number of points without exceeding 21. ''' 这个简单的游戏是两个玩家玩的。发牌人拿到一副新的牌,然后洗牌。每人发两张牌。然后每个玩家轮流上场 '''在他们的回合中,玩家可以选择“hit”,这意味着他们想要发另一张牌,或者选择“stand”,这意味着他们将束他们的回合。 '''玩家可以在回合结束前按自己的意愿“命中”多少次。一旦两名选手轮流上场,胜者就已确定。得分最多且不超过21分者为胜者。 ''' </summary> ''' <returns>Output from the game</returns> Public Function Play() As String Dim output As New StringBuilder() ' The game begins... Dim hand1 = New Hand(mPlayer1) hand1.AddCard(mDeck.Deal()) hand1.AddCard(mDeck.Deal()) Dim hand2 = New Hand(mPlayer2) hand1.AddCard(mDeck.Deal()) hand1.AddCard(mDeck.Deal()) output.AppendFormat("{0} starts with {1}{2}", hand1.Player.Name, hand1.Description, Environment.NewLine) output.AppendFormat("{0} starts with {1}{2}", hand2.Player.Name, hand2.Description, Environment.NewLine) ' Players take their turns Dim hands As New List(Of Hand)({hand1, hand2}) For Each hand As Hand In hands Dim name As String = hand.Player.Name output.AppendFormat("{0}'s turn...{1}", name, Environment.NewLine) While (hand.Player.WantsToHit(hand.TotalPoints)) Dim dealt As Card = mDeck.Deal() output.AppendFormat("{0} hits: {1}{2}", name, dealt.Description, Environment.NewLine) hand.AddCard(dealt) End While If hand.TotalPoints > 21 Then output.AppendFormat("{0} bursts.{1}", name, Environment.NewLine) Else output.AppendFormat("{0} stands.{1}", name, Environment.NewLine) End If Next ' Determine the winner If hand1.Beats(hand2) Then output.AppendFormat("{0} WINS!{1}", hand1.Player.Name, Environment.NewLine) ElseIf hand2.Beats(hand1) Then output.AppendFormat("{0} WINS!{1}", hand2.Player.Name, Environment.NewLine) Else output.AppendFormat("It's a DRAW!{0}", Environment.NewLine) End If Return output.ToString() End Function End Class ``` ''' <summary> ''' Represents the collection of cards that have been dealt to a player. ''' 表示已分发给玩家的纸牌集合 ''' </summary> Public Class Hand ''' <summary> ''' The cards currently held in this hand ''' </summary> Private mCards As List(Of Card) ''' <summary> ''' The player to whom this hand belongs ''' </summary> Private mPlayer As Player ''' <summary> ''' Constructs a new hand for the specified player. ''' </summary> ''' <param name="player">The player to whom this hand belongs</param> Public Sub New(player As Player) mPlayer = player mCards = New List(Of Card)() End Sub ''' <summary> ''' Returns the player that this hand belongs to. ''' </summary> ''' <returns>player</returns> Public ReadOnly Property Player As Player Get Return mPlayer End Get End Property ''' <summary> ''' Adds a card to the hand ''' </summary> ''' <param name="card">the card to be added</param> Public Sub AddCard(card As Card) mCards.Add(card) End Sub ''' <summary> ''' Returns the total points for this hand by adding up the points of each card. ''' </summary> ''' <returns>total points</returns> Public ReadOnly Property TotalPoints As Integer Get Dim points As Integer = 0 For i As Integer = 0 To (mCards.Count - 1) points += mCards(i).Points Next Return points End Get End Property ''' <summary> ''' Determines whether this hand is better than the other player's hand. ''' 确定这手牌是否比其他玩家的那手牌好 ''' In general, the winning hand is the hand with the greatest number of points. ''' 一般来说,获胜的手是得分最多的手 ''' But, if the hand exceeds 21 then it is a "bust" - the other player wins. ''' 但是,如果这只手超过21,那么它就是一个“半身像”——另一个玩家赢了 ''' If both players bust, or if their total points are the same, then it is a draw. ''' 如果双方球员都失败了,或者他们的总得分相同,那么就是平局 ''' </summary> ''' <param name="other">the hand to compare against</param> ''' <returns>True, if this is a better hand than the specified other hand</returns> Public Function Beats(other As Hand) As Boolean Dim myScore As Integer = TotalPoints If myScore > 21 Then Return False End If Dim otherScore As Integer = other.TotalPoints If otherScore > myScore Then Return False End If Return True End Function ''' <summary> ''' Returns a formatted description of the cards in the hand, suitable for screen output ''' </summary> ''' <returns>Description of the hand</returns> Public ReadOnly Property Description As String Get Dim desc As New StringBuilder() desc.Append(mCards.Count) desc.Append(" cards: ") Dim first As Boolean = True For Each card As Card In mCards If Not first Then desc.Append(", ") End If desc.Append(card.Description) first = False Next desc.Append(".") Return desc.ToString() End Get End Property End Class ``` ''' <summary> ''' Represents a player, and their decision making logic for whether to ''' "hit" or "stand" ''' </summary> Public Class Player ''' <summary> ''' A friendly name that identifies the player. ''' 一个识别玩家的友好名字 ''' </summary> Private mName As String ''' <summary> ''' Used for calculating probability of bust ''' 用于计算破产概率 ''' </summary> Private mProbabilityCalculator As ProbabilityCalculator ''' <summary> ''' Constructor. ''' </summary> ''' <param name="name">player's name</param> ''' <param name="probabilityCalculator">for calculating probability of bust</param> ''' <remarks></remarks> Public Sub New(name As String, probabilityCalculator As ProbabilityCalculator) mName = name mProbabilityCalculator = probabilityCalculator End Sub ''' <summary> ''' Returns the player's name ''' </summary> ''' <returns>name</returns> Public ReadOnly Property Name As String Get Return mName End Get End Property ''' <summary> ''' Determines whether the player would like to "hit" (have another card dealt to their hand), ''' or "stand" (end their turn). ''' In this simple implementation, the player's strategy is to hit, so long as they are more likely ''' to increase their points than they are to bust. ''' If their current points are at 21, they should always stay ''' If their current points are at 10 or below, they can never bust, so they should always hit ''' For points in between, they will hit so long as the probability of the next draw causing a bust is less ''' than 50%. ''' 决定玩家是想“击中”(手上有另一张牌),还是“站着”(结束他们的回合)。在这个简单的实现中,玩家的策略是命中, ''' 只要他们更有可能增加他们的点数而不是失败。如果他们现在的分数是21分,他们应该一直保持下去 '''如果他们现在的点数是10点或以下,他们永远不会破产,所以他们应该总是击中中间的点数,只要下一次平局导致破产的概率小于50%,他们就会击中。 ''' </summary> ''' <param name="currentPoints">The total of the cards currently held by this player</param> ''' <remarks>True if the players wants to "hit", false if they want to "stand".</remarks> Public Function WantsToHit(currentPoints As Integer) If currentPoints >= 21 Then Return False ElseIf currentPoints <= 10 Then Return True Else Return mProbabilityCalculator.CalculateProbability(currentPoints) < 0.5 End If End Function End Class ``` ''' <summary> ''' Used by the player's hit/stand decision making, to determine the probability of busting if ''' they deal another card. ''' 用于玩家的命中/立场决策,以确定如果他们发另一张牌失败的概率 ''' </summary> Public Class ProbabilityCalculator ''' <summary> ''' All possible cards ''' </summary> Private mFullDeck As List(Of Card) Public Sub New(fullDeck As List(Of Card)) mFullDeck = fullDeck End Sub ''' <summary> ''' Determines the probability of a "bust" if the players deals one more card into their hand. ''' A "bust" occurs if the next card takes their total over 21. ''' 确定一个“破产”的概率,如果玩家在他们的手上多出一张牌。如果下一张牌的总数超过21,就会发生“破产” ''' ''' The probability is simulated as follows: ''' Consider all possible cards that might be dealt next if the player chooses to "hit". ''' (Since "card counting" is a no-no in Blackjack, we imagine that *any* of the cards from a ''' normal full deck could be dealt next. ie. don't exclude cards that have already been dealt). ''' For each possibility, determine the total points that would be achieved if that card ''' were added to the player's hand, and decide whether or not it is a bust. ''' The probability of a bust is the percentage of all the combinations tried that resulted in a bust. ''' 概率模拟如下: 考虑一下,如果玩家选择“命中”,接下来可能要发的所有牌。 '''(由于“数牌”在21点游戏中是不允许的,我们认为接下来可以处理任何一张普通的整副牌中的牌。ie。不要排除已经发过的牌)。 '''对于每一种可能性,确定如果那张牌可以获得的总积分 被添加到玩家手上,并决定它是否是一个破产。 '''破产的概率是所有尝试过的导致破产的组合的百分比。 ''' ''' For example, if the player's current total is 12, then dealing any card worth 10 points ''' will result in a bust. Out of the 52 cards in a deck, 16 of them are worth 10 points (the Tens, Jacks, ''' Queens and Kings of Spades, Hearts, Clubs and Diamonds). So, the probability of a bust ''' is 0.3077 (30.77%), which is 16 divided by 52. ''' Similarly, if the player's current total is 19, there are 44 possible cards that will result in ''' a bust (everything except the aces and twos), and so the probability is 0.8462. ''' 例如,如果玩家当前的总数是12,那么处理任何值10分的牌 会导致破产。在一副牌中的52张牌中,16张值10分(10,j,黑桃、红桃、梅花和方块的王后和国王)。 ''' 因此,破产的概率是0.3077(30.77%)也就是16除以52。同样的,如果玩家当前的总数是19,那么有44张可能导致失败的牌(除了a和2以外的所有牌),所以概率是0.8462。 ''' </summary> ''' <param name="currentPoints">the total points for the player's current hand</param> ''' <returns>probability of a bust if one more card is dealt (0.5f = 50%)</returns> Public Function CalculateProbability(currentPoints As Integer) As Decimal ' Problem: we can't calculate the probability if we don't have any cards to simulate with. ' This shouldn't happen, but to prevent potential crashes, we'll return 50% ' 问题:如果我们没有卡片来模拟,我们就无法计算概率。这不应该发生,但为了防止潜在的崩溃,我们将返回50% If mFullDeck.Count = 0 Then Return 0.5 End If Dim numberOfBusts As Integer = 0 Dim numberOfNonBusts As Integer = 0 For Each card As Card In mFullDeck Dim potentialPoints = currentPoints + card.Points If (potentialPoints > 21) Then numberOfBusts += 1 Else numberOfNonBusts += 1 End If Next Return numberOfBusts / CType(numberOfNonBusts, Decimal) End Function End Class ``` ``` ```
VB读取dat格式的数据文件中怎么只读取原始数据,而忽略读取插值产生的模拟数据?
VB读取dat格式的数据文件中怎么只读取原始数据,而忽略读取插值产生的模拟数据?怎么避免读取伪数据呢?
vb可以读取c++的消息队列里的消息么?
使用vb和c++创建的消息内存的地址分配是一样的么?vb可以读取c++的消息队列里的消息么?
NI-9213和VB6.0的通信
1 VB6.0 和NI-9213这类温度采集的通信如何实现,新的NIDAQMAX 没有例子? 2 求大神给帮忙提供例子或给出开发的DELL,跪求高手。
关于vb.net读取excel的问题
vs2015 Microsoft Excel 16.0 Object Library MyExcel = New Microsoft.Office.Interop.Excel.Application MyExcel.Visible = False ExcWorksbook = MyExcel.Workbooks.Open("D:\Info.xlsx") ExcSheet = ExcWorksbook.Sheets(1) ExcWorksbook.Close() MyExcel.Quit() 其中 ExcSheet = ExcWorksbook.Sheets(1) ,这一句总是报错,无论是写sheet(1)还是sheets("Sheet1")。 错误提示是:“System.InvalidCastException”类型的未经处理的异常在 公式单小助手.exe 中发生 其他信息: 无法将类型为“System.__ComObject”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Excel.Sheets”。此操作失败的原因是对 IID 为“{000208D7-0000-0000-C000-000000000046}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 不支持此接口 (异常来自 HRESULT:0x80004002 (E_NOINTERFACE))。 请问如何解决,谢谢 另外,看到网上的vb.net 读取excel是可以用sheet(x).cells(x,y)这种写法的,但是我在sheet(x)后面打上“.”以后,后面的提示并没有cells,这是为什么呢? 谢谢
怎么通过VB6.0从PC电脑屏幕发送文字和图片短消息到手机上的微信软件?
怎么通过VB6.0从PC电脑屏幕发送文字和图片短消息到手机上的微信软件?微信软件怎么接收来自PC电脑屏幕的消息?
相见恨晚的超实用网站
相见恨晚的超实用网站 持续更新中。。。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
python 简易微信实现(注册登录+数据库存储+聊天+GUI+文件传输)
socket+tkinter详解+简易微信实现 历经多天的努力,查阅了许多大佬的博客后终于实现了一个简易的微信O(∩_∩)O~~ 简易数据库的实现 使用pands+CSV实现数据库框架搭建 import socket import threading from pandas import * import pymysql import csv # 创建DataFrame对象 # 存储用户数据的表(...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
JavaScript 为什么能活到现在?
作者 | 司徒正美 责编 |郭芮 出品 | CSDN(ID:CSDNnews) JavaScript能发展到现在的程度已经经历不少的坎坷,早产带来的某些缺陷是永久性的,因此浏览器才有禁用JavaScript的选项。甚至在jQuery时代有人问出这样的问题,jQuery与JavaScript哪个快?在Babel.js出来之前,发明一门全新的语言代码代替JavaScript...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
吐血推荐珍藏的Visual Studio Code插件
作为一名Java工程师,由于工作需要,最近一个月一直在写NodeJS,这种经历可以说是一部辛酸史了。好在有神器Visual Studio Code陪伴,让我的这段经历没有更加困难。眼看这段经历要告一段落了,今天就来给大家分享一下我常用的一些VSC的插件。 VSC的插件安装方法很简单,只需要点击左侧最下方的插件栏选项,然后就可以搜索你想要的插件了。 下面我们进入正题 Material Theme ...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
开源并不是你认为的那些事
点击上方蓝字 关注我们开源之道导读所以 ————想要理清开源是什么?先要厘清开源不是什么,名正言顺是句中国的古代成语,概念本身的理解非常之重要。大部分生物多样性的起源,...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Python 植物大战僵尸代码实现(2):植物卡片选择和种植
这篇文章要介绍的是: - 上方植物卡片栏的实现。 - 点击植物卡片,鼠标切换为植物图片。 - 鼠标移动时,判断当前在哪个方格中,并显示半透明的植物作为提示。
相关热词 c#委托 逆变与协变 c#新建一个项目 c#获取dll文件路径 c#子窗体调用主窗体事件 c# 拷贝目录 c# 调用cef 网页填表c#源代码 c#部署端口监听项目、 c#接口中的属性使用方法 c# 昨天
立即提问