'純數字轉換系統
Public Class Form1
Dim D2B As String
Dim Dec As Integer
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dec = InputBox("請輸入0~255之間的任意數字")
D2B = ""
Do While Dec > 0
D2B = Dec Mod 2 & D2B
Dec = Dec \ 2
Loop
MsgBox(D2B)
End
End Sub
End Class
'將位數補齊為8位數
Public Class Form1
Dim D2B As String
Dim Dec As Integer
Dim supply As String
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dec = InputBox("請輸入0~255之間的任意數字")
D2B = ""
Do While Dec > 0
D2B = Dec Mod 2 & D2B
Dec = Dec \ 2
Loop
checkD2B(D2B)
MsgBox(D2B)
End
End Sub
Sub checkD2B(ByRef D2B As String)
'當二進位數字長度小於八位數時,將其數字補齊。
If Len(D2B) < 8 Then
For i = 1 To 8 - Len(D2B)
supply &= "0"
Next
End If
D2B = supply & D2B
End Sub
End Class
2019年4月25日 星期四
2019年4月24日 星期三
2019年4月14日 星期日
判斷輸入的數字是否為質數,並求出該值的所有正負因數。
Public Class Form1
Dim i
Dim str1
Dim str2
Dim ans As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim n As Integer = InputBox("請輸入一個數值")
'求正數因數
For i = 1 To n
If n Mod i = 0 Then
str1 = str1 & i & " "
End If
Next
Dim factor() As String = Split(str1, " ")
Dim factornum As Integer = UBound(factor)
If factornum = 2 Then
ans = "這是一個質數。"
Else
ans = "這是一個合數。"
End If
'求負數因數
Dim factor2() As String = Split(str1, " ")
For i = 0 To UBound(factor2)
factor2(i) = "-" & factor2(i)
str2 &= factor2(i) & " "
Next
str2 = Strings.Left(str2, Len(str2) - 3)
MsgBox(ans & vbCrLf & "這個數字的正因數包含:" & str1 & vbCrLf & "這個數字的負因數包含:" & str2)
End
End Sub
End Class
-------------------
另解:
'UBound函數功能為求出該陣列的個數,因For迴圈從0開始,因此會重複迴圈一次,故,我們可以改為UBound(factor2) - 1,回歸到原陣列個數,如使用這種方式,則可以省去在最後輸出前再進行一次去尾的動作。
Dim factor2() As String = Split(str1, " ")
For i = 0 To UBound(factor2) - 1
factor2(i) = "-" & factor2(i)
str2 &= factor2(i) & " "
Next
2019年4月13日 星期六
小柯茶行開張囉!
Public Class Form1
Dim a(12) As Integer
Dim sum(12) As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
a(0) = TextBox1.Text
sum(0) = a(0) * 25
Label10.Text = "共" & sum(0) & "元"
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
a(1) = TextBox2.Text
sum(1) = a(1) * 30
Label11.Text = "共" & sum(1) & "元"
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
a(2) = TextBox3.Text
sum(2) = a(2) * 25
Label12.Text = "共" & sum(2) & "元"
End Sub
Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
a(3) = TextBox4.Text
sum(3) = a(3) * 30
Label13.Text = "共" & sum(3) & "元"
End Sub
Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
a(4) = TextBox5.Text
sum(4) = a(4) * 35
Label18.Text = "共" & a(4) * 35 & "元"
End Sub
Private Sub TextBox6_TextChanged(sender As Object, e As EventArgs) Handles TextBox6.TextChanged
a(5) = TextBox6.Text
sum(5) = a(5) * 40
Label19.Text = "共" & a(5) * 40 & "元"
End Sub
Private Sub TextBox7_TextChanged(sender As Object, e As EventArgs) Handles TextBox7.TextChanged
a(6) = TextBox7.Text
sum(6) = a(6) * 45
Label20.Text = "共" & a(6) * 45 & "元"
End Sub
Private Sub TextBox8_TextChanged(sender As Object, e As EventArgs) Handles TextBox8.TextChanged
a(7) = TextBox8.Text
sum(7) = a(7) * 50
Label21.Text = "共" & a(7) * 50 & "元"
End Sub
Private Sub TextBox16_TextChanged(sender As Object, e As EventArgs) Handles TextBox16.TextChanged
a(8) = TextBox16.Text
sum(8) = a(8) * 50
Label22.Text = "共" & sum(8) & "元"
End Sub
Private Sub TextBox15_TextChanged(sender As Object, e As EventArgs) Handles TextBox15.TextChanged
a(9) = TextBox15.Text
sum(9) = a(9) * 40
Label23.Text = "共" & sum(9) & "元"
End Sub
Private Sub TextBox14_TextChanged(sender As Object, e As EventArgs) Handles TextBox14.TextChanged
a(10) = TextBox14.Text
sum(10) = a(10) * 70
Label24.Text = "共" & sum(10) & "元"
End Sub
Private Sub TextBox13_TextChanged(sender As Object, e As EventArgs) Handles TextBox13.TextChanged
a(11) = TextBox13.Text
sum(11) = a(11) * 90
Label25.Text = "共" & sum(11) & "元"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim tol As Integer
For i = 0 To 11
tol += sum(i)
Next
Label26.Text = "本次結帳" & vbCrLf & "共" & tol & "元"
End Sub
End Class
2019年4月7日 星期日
2019年4月6日 星期六
2019年4月5日 星期五
台中家商與巴基斯坦學校國際交流
心得記錄:
補0403
今天又遇到新的技術問題
這又是另一種網路傳輸層面的問題了
中午的時候我陪我們學校的應外科主任在閱覽室實驗設備,主要協助台中家商師生及巴基斯坦學校(Government Girls Elementary School SHAHANI Bhakkar Punjab Pakistan)的Noureen老師互相分享健康食品和健康飲食習慣
這次我所遇到的問題是
老師所使用的軟體是Skype
(講白一點,我上次自創帳號應該是幼稚園國小的事情了)
都還不會使用
突然就變成了手機版上操作
說真的如果是國際視訊交流
Skype的確是非常常見的軟體
在交流的時候,我們這邊勉強可以聽到對方的聲音而已
聽老師說,我們只能猜對方講什麼
然後回對方簡單的回應這樣
我試過了(電腦用的)喇叭
特別括起來是因為後來組長跟我說這種線接電腦跟接手機是沒差的
所以後來我也有在想是傳輸的問題
後來,老師當下的問題反映是
跟學生借耳機麥克風希望可以聽清楚一點
因為實際操作者不是我了
所以實際結果不是很清楚\
(我們還試了藍芽喇叭+無線傳輸投影+數據分享器…)
我這次遇到的問題,後來發現其實是我們這邊的網路不夠
在當下,我跟我的老師們還以為台灣的4G網路已經夠了
又加上老師用的是吃到飽
應該會很順才對
但實際上事與願違
如果下次再遇到類似的活動
一定要改為電腦版連接網路線
它的傳輸速度跟畫質才夠
俗話說:學以致用、用以致學
在教室讀的,都是課本的理論
都是死的
只有跳脫出那個空間,實際去摸它
才知道問題所在
才知道課本為何這樣寫阿...
(有時候課本還真的沒寫,全部要你自己摸呢!)
感謝雪麗,真的又賺一次經驗了!
(經驗無價,老師能夠送我多一次的經驗,我就心滿意足了!)
(借老師的照片一用)
訂閱:
文章 (Atom)