Hi 223
Zip Folder Below for Sample Spreadsheet DLL
https://bdp.betfair.com/index.php?op...catid=59&id=11
Dave
Using VB2008 to acccess the Betfair API: A tutorial
Collapse
This topic is closed.
X
X
-
The reason I need an exe file is that I want to call it from Excel VBA. If somebody could explain how I can create a dll in VB2010 so that I can use the methods in my Excel VBA application then it wouldn't matter why it fails!
Leave a comment:
-
Async calls and global variables
Hyperthetical question surrounding async calls and global variables.
I have a timer event that 'ticks' every minute.
Sometimes the tick event hnadler takes longer than one minute to process the information. What happens when the tick events overlap? Do they overlap? I'm particularly interested to know that if they do overlap then what happens to global variables when different tick events access them.
I'll give a scenario to explain what I'm getting at.
Timer has been started with a 1 minute interval.
1 minute elapses and the tick event is triggered (let's call it TickEvent1)
TickEvent1 assign global vatiable Var1 to 0
TickEvent1 does some processing and changes Var1 to 5
TickEvent1 does some more processing
TickEvent2 starts
TickEvent2 assign global vatiable Var1 to 0
TickEvent1 is still processing and uses the Var1 variable in a calculation
However, Var1 has been changed by TickEvent2 to 0 but Tickevent1 needs Var1 to be 5.
Can you see my problem?
Leave a comment:
-
Thanks Dave. I had figured out how to create the exe file, but I went through your processes and created it again. But it still gives an error. When I run it in VS2010 it runs fine. It's just the simple login example with the 3 buttons "login", "logout" and "keepalive".
The login call gives the error:
Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error...
And under Details:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 84.20.200.10:443
What might be the reason that the exe fails but not the project?
Leave a comment:
-
exe App
Hi 223
For a PC etc Use a Flash Drive or CD/DVD if you want to Install on another Computer besides your own
Or Just Install to a Folder on your Comp
Example Your Project Name is 'BFTest'
Either Way - Create a New Folder for your App (Say on Desktop if not in your Flash etc Name it eg "BFTest Install")
For First Time Install its Best to Add a Desktop ShortCut before Publishing So in VB2010 Main Menu Click
Project - "BFTest Properties" (Ignore Publish BFTest this Time)
In Properties - Select "Publish"
1-In the Top Publish Location Browse to your "BFTest Install" Folder
2- Select the "(Launchable from Start Menu") Option
3 - Click Options (You can Play with all this later )but for now
4- Click Manifests
5 - Tick "Create DeskTop Shortcut" (If you add or have added an icon to your project it will show this on your Desktop Do that from BFTest Properties -Application - Add Icon Link) for now it will just use the vb default - Click Ok
6 - then Click "Publish Now" It will show in your status bar publishing and if it succeeded
Finally go to your Installation Folder and Double Click the Setup.exe and it will install like any other Program
It will show a Desktop Icon and Start Menu and will also be in your Uninstall Programs from the Control Panel
After Doing the above you only need to Use the VB Main Menu
Project - Publish BFTest and Click Finish in the Dialogue
This will Update your Publication each time so you can just use Setup.exe to keep your application updated with your latest Project version you are working on
Also handy to Test your Project "live" while you can make any adjustments in the VBStudio in your project at the same time without the debugger
Hope this Helps
Dave
PS Forgot to mention you can also locate in your Project files
The Bin Folder and use the .exe file from The Release Folder (NOT Debug folder)
Leave a comment:
-
Excellent thread. Wish I'd found it a long time ago!
The app works fine in VS2010 but when I create a .exe file for the simplest version, it falls over when logging in. What's the best way to create a .exe file?
Thanks
Leave a comment:
-
Hey, now thats first-hand help
Thank you very much
PS: Your Tutorial is just great! I didn't know anything about VB and now just after reading and trying to understand whats going on in your tutorial I get all things done, even by myself so far
I would certainly donate a few dollars if you had asked. A good guy you are!
Leave a comment:
-
Geierkind,
The " placeholder" characters (*, #, etc.) have no special meaning within a VB string. Probably easiest to use the String.Contains method, for example:
If .marketName.Contains("Clean Sheet") Then
You could also use the InStr function.
Note that the substring comparison is case-sensitive.
Leave a comment:
-
Hi
I got a small problem here:
I will present a sub for showing Prices of AllMarkets (usual stuff). But in it I will filter Cleansheet markets. This is no problem for 3way bets since the condition string will just be "MatchOdds" or in german language "Wettquoten". But for Cleansheet-Markets betfair doesnt provide all markets in one language but mixes the Strings. So far.
Now it gets a bit worse for my very little experience with VB, because I dont really know how to write placeholders in the string. And since the market-names for Cleansheet-Bets contain(!) the name of any team, I would like to use them. Thanks for any help. This would be my sub, and my idea for the solution, which just doesn't find any markets in AllMarkets which fit the condition. Thanks for any help!
Code:Private Sub clsprices_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clsprices.Click tLog.Text = "" With AllMarkets For j = 0 To AllMarkets.marketData.Length - 1 If AllMarkets.marketData(j).marketName = "*Clean Sheet*" Or AllMarkets.marketData(j).marketName = "*ohne Gegentor*" Then iMarket = j ShowMprices(BetFairUK.getMarketPrices(MpricesReq)) 'Get market prices End If End With End SubLast edited by Geierkind; 14-08-2011, 11:35 PM.
Leave a comment:
-
Thanks BigSprout.
I ended up using getMarketPricesCompressed and the code on step14.
If someone wants to know how to do a small ladder using textbox's to display the 3 best back and lay prices this is the part of the Mumble0's code I changed:
It's working just fineCode:Private Sub BetFairUK_getMarketPricesCompressedCompleted(ByVal sender As Object, ByVal e As BFUK.getMarketPricesCompressedCompletedEventArgs) Handles BetFairUK.getMarketPricesCompressedCompleted Dim id0, id1 As String id0 = Val(bSelecid.Text) id1 = Val(bSelectid1.Text) Try If Not e.Cancelled Then With e.Result CheckHeader(.header) Print("ErrorCode = " & .errorCode.ToString) If .errorCode = BFUK.GetMarketPricesErrorEnum.OK Then Dim oMarketPrices As New UnpackMarketPricesCompressed(.marketPrices) With oMarketPrices For i = 0 To .runnerPrices.Length - 1 With .runnerPrices(i) If .selectionId = id0 Then If .bestPricesToBack.Length > 0 Then aB0.Text = .bestPricesToBack(0).price aBA0.Text = Int(.bestPricesToBack(0).amountAvailable) End If If .bestPricesToBack.Length > 1 Then aB1.Text = .bestPricesToBack(1).price aBA1.Text = Int(.bestPricesToBack(1).amountAvailable) End If If .bestPricesToBack.Length > 2 Then aB2.Text = .bestPricesToBack(2).price aBA2.Text = Int(.bestPricesToBack(2).amountAvailable) End If If .bestPricesToLay.Length > 0 Then aL0.Text = .bestPricesToLay(0).price aLA0.Text = Int(.bestPricesToLay(0).amountAvailable) End If If .bestPricesToLay.Length > 1 Then aL1.Text = .bestPricesToLay(1).price aLA1.Text = Int(.bestPricesToLay(1).amountAvailable) End If If .bestPricesToLay.Length > 2 Then aL2.Text = .bestPricesToLay(2).price aLA2.Text = Int(.bestPricesToLay(2).amountAvailable) End If End If If .selectionId = id1 Then If .bestPricesToBack.Length > 0 Then bB0.Text = .bestPricesToBack(0).price bBA0.Text = Int(.bestPricesToBack(0).amountAvailable) End If If .bestPricesToBack.Length > 1 Then bB1.Text = .bestPricesToBack(1).price bBA1.Text = Int(.bestPricesToBack(1).amountAvailable) End If If .bestPricesToBack.Length > 2 Then bB2.Text = .bestPricesToBack(2).price bBA2.Text = Int(.bestPricesToBack(2).amountAvailable) End If If .bestPricesToLay.Length > 0 Then bL0.Text = .bestPricesToLay(0).price bLA0.Text = Int(.bestPricesToLay(0).amountAvailable) End If If .bestPricesToLay.Length > 1 Then bL1.Text = .bestPricesToLay(1).price bLA1.Text = Int(.bestPricesToLay(1).amountAvailable) End If If .bestPricesToLay.Length > 2 Then bL2.Text = .bestPricesToLay(2).price bLA2.Text = Int(.bestPricesToLay(2).amountAvailable) End If End If End With Next End With End If End With End If Catch ex As ApplicationException Print(e.Error.Message) End Try End Sub
Leave a comment:
-
Camper,
this type of error causes the problems you are getting (clearing the wrong text box):
I think it would be in your best interest to get some books on programming in VB2010 and also check if there is any suitable courses being run at any of your local schools/colleges/universities that you can attend.Code:If .bestPricesToLay.Length > 2 Then With .bestPricesToLay(2) TextBox34.Text = Format(.price, "0.00") [COLOR="Red"]TextBox32.Text[/COLOR] = Format(.amountAvailable, "0") End With Else TextBox34.Text = "" [COLOR="Red"]TextBox33.Text[/COLOR] = "" End If
The errors you are making will most probably be very costly if they continue into placing bets code
Leave a comment:
-
Still with the same errors.
The code I'm using:
Output:Code:Sub showmprices(ByVal mpriceresp As BFUK.GetMarketPricesResp) Dim id0, ms, mid, id1 As String ms = Val(bMstatus.Text) mid = Val(bMarkid.Text) id0 = Val(bSelecid.Text) id1 = Val(bSelectid1.Text) With mpriceresp CheckHeader(.header) Print("errorcode = " & .errorCode.ToString) If .errorCode = BFUK.GetMarketPricesErrorEnum.OK Then With .marketPrices ms = .marketStatus mid = .marketId For i = 0 To .runnerPrices.Length - 1 With .runnerPrices(i) If .selectionId = id0 Then If .bestPricesToBack.Length > 0 Then With .bestPricesToBack(0) aB0.Text = Format(.price, "0.00") aBA0.Text = Format(.amountAvailable, "0") End With Else aB0.Text = "" aBA0.Text = "" End If If .bestPricesToLay.Length > 0 Then With .bestPricesToLay(0) aL0.Text = Format(.price, "0.00") aLA0.Text = Format(.amountAvailable, "0") End With Else aL0.Text = "" aLA0.Text = "" End If If .bestPricesToBack.Length > 1 Then With .bestPricesToBack(1) aB1.Text = Format(.price, "0.00") aBA1.Text = Format(.amountAvailable, "0") End With Else aB1.Text = "" aBA1.Text = "" End If If .bestPricesToLay.Length > 1 Then With .bestPricesToLay(1) aL1.Text = Format(.price, "0.00") aLA1.Text = Format(.amountAvailable, "0") End With Else aL1.Text = "" aLA1.Text = "" End If If .bestPricesToBack.Length > 2 Then With .bestPricesToBack(2) aB2.Text = Format(.price, "0.00") aBA2.Text = Format(.amountAvailable, "0") End With Else aB2.Text = "" aBA2.Text = "" End If If .bestPricesToLay.Length > 2 Then With .bestPricesToLay(2) aL2.Text = Format(.price, "0.00") aLA2.Text = Format(.amountAvailable, "0") End With Else aL2.Text = "" aLA2.Text = "" End If End If If .selectionId = id1 Then If .bestPricesToBack.Length > 0 Then With .bestPricesToBack(0) bB0.Text = Format(.price, "0.00") TextBox3.Text = Format(.amountAvailable, "0") End With Else bB0.Text = "" TextBox3.Text = "" End If If .bestPricesToLay.Length > 0 Then With .bestPricesToLay(0) bL0.Text = Format(.price, "0.00") TextBox1.Text = Format(.amountAvailable, "0") End With Else bL0.Text = "" TextBox1.Text = "" End If If .bestPricesToBack.Length > 1 Then With .bestPricesToBack(1) TextBox43.Text = Format(.price, "0.00") TextBox42.Text = Format(.amountAvailable, "0") End With Else TextBox43.Text = "" TextBox42.Text = "" End If If .bestPricesToLay.Length > 1 Then With .bestPricesToLay(1) TextBox35.Text = Format(.price, "0.00") TextBox33.Text = Format(.amountAvailable, "0") End With Else TextBox35.Text = "" TextBox33.Text = "" End If If .bestPricesToBack.Length > 2 Then With .bestPricesToBack(2) TextBox41.Text = Format(.price, "0.00") TextBox40.Text = Format(.amountAvailable, "0") End With Else TextBox41.Text = "" TextBox40.Text = "" End If If .bestPricesToLay.Length > 2 Then With .bestPricesToLay(2) TextBox34.Text = Format(.price, "0.00") TextBox32.Text = Format(.amountAvailable, "0") End With Else TextBox34.Text = "" TextBox33.Text = "" End If End If End With Next End With End If End With End Sub

The real values on Betfair:

This is driving me nuts.
I thought it may be better to use getMarketPricesCompressed because it returns the best 3 available back prices and the best 3 available lay prices with amounts available, exactly what I need. I'll try and let you know.Last edited by Camper; 11-08-2011, 01:38 AM.
Leave a comment:
-
Camper,
this could be because you aren't clearing your text boxes, e.g:
TextBox34.text displays "3.45" when you 1st read in price data, then the next time there is no data for .bestPricesToLay(2) and so TextBox34.text still displays "3.45" (remains the same) and seems to be reading incorrect data.
You need to clear the displays if no data is available:
Code:If .bestPricesToLay.Length > 2 Then With .bestPricesToLay(2) TextBox34.Text = Format(.price, "0.00") TextBox32.Text = Format(.amountAvailable, "0") end with [COLOR="Red"]else TextBox34.text="" TextBox32.Text=""[/COLOR] end if
Leave a comment:
-
Thanks for your help
I did as you said but a strange thing is happening.
The code I'm using now is this:
I'm getting wrong values everywhere, sometimes the prices are working great, sometimes other values are shown (5th best price or greater) and other times no value at all.Code:Sub ShowMprices(ByVal MpriceResp As BFUK.GetMarketPricesResp) With MpriceResp CheckHeader(.header) Print("ErrorCode = " & .errorCode.ToString) If .errorCode = BFUK.GetMarketPricesErrorEnum.OK Then With .marketPrices Dim MS As String MS = Val(bMstatus.Text) MS = .marketStatus Dim MID As String MID = Val(bMarkid.Text) MID = .marketId With .runnerPrices(0) Dim Id0 As String Id0 = Val(bSelecid.Text) Id0 = .selectionId If .bestPricesToBack.Length > 0 Then With .bestPricesToBack(0) aB0.Text = Format(.price, "0.00") aBA0.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToLay.Length > 0 Then With .bestPricesToLay(0) aL0.Text = Format(.price, "0.00") aLA0.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToBack.Length > 1 Then With .bestPricesToBack(1) aB1.Text = Format(.price, "0.00") aBA1.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToLay.Length > 1 Then With .bestPricesToLay(1) aL1.Text = Format(.price, "0.00") aLA1.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToBack.Length > 2 Then With .bestPricesToBack(2) aB2.Text = Format(.price, "0.00") aBA2.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToLay.Length > 2 Then With .bestPricesToLay(2) aL2.Text = Format(.price, "0.00") aLA2.Text = Format(.amountAvailable, "0") End With End If End With With .runnerPrices(1) Dim Id1 As String Id1 = Val(bSelectid1.Text) Id1 = .selectionId If .bestPricesToBack.Length > 0 Then With .bestPricesToBack(0) bB0.Text = Format(.price, "0.00") TextBox3.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToLay.Length > 0 Then With .bestPricesToLay(0) bL0.Text = Format(.price, "0.00") TextBox1.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToBack.Length > 1 Then With .bestPricesToBack(1) TextBox43.Text = Format(.price, "0.00") TextBox42.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToLay.Length > 1 Then With .bestPricesToLay(1) TextBox35.Text = Format(.price, "0.00") TextBox33.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToBack.Length > 2 Then With .bestPricesToBack(2) TextBox41.Text = Format(.price, "0.00") TextBox40.Text = Format(.amountAvailable, "0") End With End If If .bestPricesToLay.Length > 2 Then With .bestPricesToLay(2) TextBox34.Text = Format(.price, "0.00") TextBox32.Text = Format(.amountAvailable, "0") End With End If End With End With Else Print("ShowMprices Error") End If End With End SubLast edited by Camper; 10-08-2011, 04:51 AM.
Leave a comment:
-
Hi Camper,
Normally the "Index out of range" error is caused by requesting data which isn't there,
e.g
there is only 1 price in Best Prices so:
so you need to test first with something like:Code:.bestPricesToBack(0).price 'would give a valid return .bestPricesToBack(1).price 'would give an "Index out of range" error
Code:if .bestPricesToBack.length>0 then with .bestPricesToBack(0) ...your code end with end if if .bestPricesToBack.length>1 then with .bestPricesToBack(1) ...your code end with end if ...etc
What you have written is okay and working well for you, so these are just a few suggestions that may help in shortening the amount of code
Code:'*** You can also decrease the amount of code written bPriceB(2) = .price TextBox41.Text = bPriceB(2) '*** can be written in one line as: TextBox41.Text = format(.price,"0.00") Dim y As Integer Dim x As Double = .amountAvailable y = Convert.ToInt32(x) TextBox40.Text = y '*** can be written in one line as: TextBox40.Text = format(.amountAvailable,"0.00") '*** or if you want it as an integer value: TextBox40.Text = format(.amountAvailable,"0")
Last edited by BigSprout; 10-08-2011, 01:40 AM.
Leave a comment:


Leave a comment: