· 6 years ago · Jan 30, 2020, 04:56 AM
1' Faith Hinojosa : Admin
2' WordMatch system
3' Used to send and receive http request among databases (oracle)
4
5' This example demonstrates a REST call using SendReqStringBody, ReadResonseHeader, and ReadRespBodyString.
6' It will create a bucket in Google Cloud Storage.
7Dim success As Long
8
9' It requires the Chilkat API to have been previously unlocked.
10' See Global Unlock Sample for sample code.
11
12Dim gAuth As New ChilkatAuthGoogle
13' Obtain an access token as shown in one of the following examples:
14' See Get Access Token using a Service Account JSON Key
15' See Get Access Token using a P12 File
16
17Dim rest As New ChilkatRest
18
19' Connect using TLS.
20Dim bAutoReconnect As Long
21bAutoReconnect = 1
22success = rest.Connect("www.googleapis.com",443,1,bAutoReconnect)
23
24' Provide the authentication credentials (i.e. the access key)
25success = rest.SetAuthGoogle(gAuth)
26
27' Build the JSON request body for creating a bucket.
28' The only required property is the "name", but we'll add more
29' to make a better example..
30Dim jsonReqBody As New ChilkatJsonObject
31success = jsonReqBody.AddStringAt(-1,"name","chilkat-bucket-c")
32success = jsonReqBody.AddStringAt(-1,"kind","storage#bucket")
33success = jsonReqBody.AddStringAt(-1,"location","US")
34success = jsonReqBody.AddObjectAt(-1,"versioning")
35
36Dim pObjVersioning As ChilkatJsonObject
37Set pObjVersioning = jsonReqBody.ObjectOf("versioning")
38success = pObjVersioning.AddBoolAt(-1,"enabled",1)
39
40' Show the HTTP request body we'll be sending.
41Text1.Text = Text1.Text & jsonReqBody.Emit() & vbCrLf
42
43' Add the required query parameter.
44' See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
45success = rest.AddQueryParam("project","chilkattest-1050")
46
47' Add the Content-Type HTTP request header.
48success = rest.AddHeader("Content-Type","application/json; charset=UTF-8")
49
50' Send the REST HTTP request.
51success = rest.SendReqStringBody("POST","/storage/v1/b",jsonReqBody.Emit())
52If (success <> 1) Then
53 Text1.Text = Text1.Text & rest.LastErrorText & vbCrLf
54 Exit Sub
55End If
56
57' Read the response header.
58Dim responseStatusCode As Long
59responseStatusCode = rest.ReadResponseHeader()
60If (responseStatusCode < 0) Then
61 ' We were unable to receive the response header.
62 Text1.Text = Text1.Text & rest.LastErrorText & vbCrLf
63 Exit Sub
64End If
65
66If (responseStatusCode <> 200) Then
67 ' The response was not successful. We'll still need to receive
68 ' the response body, which may contain an error message from the server.
69 ' If the response has no body, then the method for reading the
70 ' response body can still be called. It will simply return with an empty
71 ' response body.
72
73 ' We can examine the response header and status text:
74 Text1.Text = Text1.Text & "Response status text: " & rest.ResponseStatusText & vbCrLf
75 Text1.Text = Text1.Text & "Response header: " & rest.ResponseHeader & vbCrLf
76End If
77
78' Read the response body. In this case we're expecting it to be JSON..
79Dim responseBodyStr As String
80responseBodyStr = rest.ReadRespBodyString()
81If (rest.LastMethodSuccess <> 1) Then
82 ' We were unable to receive the response body.
83 ' Note: If the response did not include a body (such as for cases where
84 ' the Content-Length header is 0, or if the response status code implicitly
85 ' indicates no body, then ReadRespBodyString returns cktrue, and the
86 ' responseBodyString will be an empty string.
87 Text1.Text = Text1.Text & rest.LastErrorText & vbCrLf
88 Exit Sub
89End If
90
91' Show the JSON response.
92Text1.Text = Text1.Text & "Json Response: " & responseBodyStr & vbCrLf
93
94
95----------------------------------------------------------------------
96'word match source code
97
98Public Class Form1
99
100 Private random As New Random
101
102 Private firstClicked As Label = Nothing
103
104 Private secondClicked As Label = Nothing
105
106 Dim current_lvl As Integer = 1
107
108 Dim remain_elements = 10
109
110 Dim question_index As Integer = 0
111
112 Dim lvl_cnt_max = (10 * current_lvl) - 1
113
114 Dim lvl_cnt_min = lvl_cnt_max - 9
115
116 Dim questions_array = New List(Of String) From {"Question 1: Refuse to acknowledge",
117 "Question 2: Having or marked by bad fortune",
118 "Question 3: Something that interests you because it is important",
119 "Question 4: An attempt to deceive someone into believing that one can or will do something",
120 "Question 5: The remains of something that has been destroyed",
121 "Question 1: One who argues in favor of something",
122 "Question 2: Clearly and exactly presented or stated: precise or exact",
123 "Question 3: To notice or recognize a difference between people or things",
124 "Question 4: Having the ability to reason or think about things clearly",
125 "Question 5: To be greater or more than (something): to be better than (something)",
126 "Question 1: To determine the significance, worth, or condition of usually by careful appraisal and study",
127 "Question 2: Not aware of or not concerned about what is happening around one",
128 "Question 3: Make (someone or something) seem less impressive or valuable",
129 "Question 4: Secretly listen to a conversation",
130 "Question 5: Make (someone) feel very happy, animated or elated.",
131 "Question 1: Start to lose strength or momentum",
132 "Question 2: Full of or shredding light; bright or shining, especially in the dark",
133 "Question 3: Not discovered or known about; uncertain",
134 "Question 4: Giving the impression that something bad or unpleasant is going to happen",
135 "Question 5: Continuing firmly or obstinately in a course of action in spite of difficulty or opposition",
136 "Question 1: Persistence in doing something despite difficulty or delay in achieving success",
137 "Question 2: Keeping careful watch for possible danger or difficulties",
138 "Question 3: Something that is wrong and incorrect",
139 "Question 4: Invent or concoct (something), typically with deceitful intent",
140 "Question 5: A fact or situation that is observed to exist or happen, especially one whose cause or explanation is in question"
141 }
142
143
144 Dim answers_array = New List(Of String) From {"Disclaim", "Deny", "Unlucky", "Unfortunate", "Worry", "Concern", "Bluff", "Hoax", "Debris", "Waste",
145 "Proponent", "Advocate", "Specific", "Concrete", "Distinguish", "Differentiate", "Reasonable", "Rational", "Surpass", "Exceed",
146 "Evaluate", "Estimate", "Oblivious", "Clueless", "Diminish", "Decrease", "Spy", "Eavesdrop", "Exhilarate", "Thrill",
147 "Falter", "Waver", "Luminous", "Gleaming", "Obscure", "Unknown", "Menacing", "Ominous", "Persistent", "Tenacious",
148 "Tenacity", "Perseverance", "Vigilant", "Observant", "Erroneous", "Imprecise", "Fabricate", "Forge", "Occurence", "Phenomenon"}
149
150 Dim pairlist() As String
151
152 Private Sub InsertWordToPair(chosen_word)
153 pairlist.Add(chosen_word)
154 End Sub
155
156 Private Sub chosenPair()
157 If pairlist.Count = 2 Then
158
159 Else
160
161 End If
162 End Sub
163
164 Private Sub IsCorrect(array_answer)
165
166 End Sub
167
168 Private Sub trigger_message()
169 MsgBox("You must only select a pair of word.")
170 End Sub
171
172 Private Sub incorrect_word()
173 MsgBox("Your answer is incorrect.")
174 End Sub
175
176 Private Sub wrongPair()
177
178 End Sub
179
180 Private Sub AssignWordsToGrid()
181 For Each Control In TableLayoutPanel1.Controls
182 Dim wordLabel = TryCast(Control, Label)
183 If wordLabel IsNot Nothing Then
184 Dim randomNumber = random.Next(lvl_cnt_min, lvl_cnt_max)
185 lvl_cnt_max = lvl_cnt_max - 1
186 wordLabel.Text = answers_array(randomNumber)
187 wordLabel.BackColor = Color.Honeydew
188 answers_array.RemoveAt(randomNumber)
189 End If
190 Next
191 End Sub
192
193 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
194 Dim level_number_string As String = current_lvl.ToString("00")
195 Me.Text = "Match the Word: Level " + level_number_string
196
197 AssignWordsToGrid()
198 End Sub
199
200 Private Sub TableLayoutPanel1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles TableLayoutPanel1.Paint
201
202 End Sub
203
204 Private Sub clearMyPairList(myPairList)
205 Erase myPairList
206 End Sub
207
208 Private Sub wrong()
209 MsgBox("They are wrong pair!")
210 End Sub
211
212 Private Sub correct()
213 MsgBox("You are correct! They are pairs!")
214 End Sub
215
216 Private Sub click1(sender As System.Object, e As System.EventArgs) Handles Label2.Click
217 'command
218 End Sub
219
220 Private Sub click2(sender As System.Object, e As System.EventArgs) Handles Label5.Click
221 'command
222 End Sub
223
224 Private Sub click3(sender As System.Object, e As System.EventArgs) Handles Label6.Click
225 'command
226 End Sub
227
228 Private Sub click4(sender As System.Object, e As System.EventArgs) Handles Label8.Click
229 'command
230 End Sub
231
232 Private Sub click5(sender As System.Object, e As System.EventArgs) Handles Label10.Click
233 'command
234 End Sub
235
236 Private Sub click6(sender As System.Object, e As System.EventArgs) Handles Label3.Click
237 'command
238 End Sub
239
240 Private Sub click7(sender As System.Object, e As System.EventArgs) Handles Label4.Click
241 'command
242 End Sub
243
244 Private Sub click8(sender As System.Object, e As System.EventArgs) Handles Label7.Click
245 'command
246 End Sub
247
248 Private Sub click9(sender As System.Object, e As System.EventArgs) Handles Label9.Click
249 'command
250 End Sub
251
252 Private Sub click10(sender As System.Object, e As System.EventArgs) Handles Label11.Click
253 'command
254 End Sub
255End Class