Visual Studio?2013
成都創(chuàng)新互聯(lián)長(zhǎng)期為數(shù)千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為永清企業(yè)提供專(zhuān)業(yè)的成都網(wǎng)站建設(shè)、做網(wǎng)站,永清網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。
Microsoft Visual Studio(簡(jiǎn)稱(chēng)VS)是美國(guó)微軟公司的開(kāi)發(fā)工具包系列產(chǎn)品。VS是一個(gè)基本完整的開(kāi)發(fā)工具集,它包括了整個(gè)軟件生命周期中所需要的大部分工具,如UML工具、代碼管控工具、集成開(kāi)發(fā)環(huán)境(IDE)等等。所寫(xiě)的目標(biāo)代碼適用于微軟支持的所有平臺(tái),包括Microsoft Windows、Windows Mobile、Windows CE、.NET Framework、.NET Compact Framework和Microsoft?Silverlight?及Windows Phone。?Visual Studio是目前最流行的Windows平臺(tái)應(yīng)用程序的集成開(kāi)發(fā)環(huán)境。最新版本為 Visual Studio 2013 版本,基于.NET Framework?4.5.1 。
下面這段代碼,是我用來(lái)計(jì)算每個(gè)月存500元進(jìn)銀行,連續(xù)30年,最后連本帶利能有多少錢(qián)。這里面涉及復(fù)利計(jì)算。界面中右邊的文本框用來(lái)輸出每一次計(jì)算的結(jié)果。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
? Dim nianxian As Integer '年限變量
? Dim dingcun As Integer '定存變量
? Dim fuli_big As Long '大復(fù)利
? Dim fuli_small As Long '小復(fù)利
? Dim i As Integer '循環(huán)變量
? Dim DATAstring As String '數(shù)據(jù)字符串
? nianxian = Val(年限_TextBox.Text)
? dingcun = Val(定存_TextBox.Text)
? DATAstring = ""
? For i = 1 To nianxian
? ? ? fuli_small = dingcun * (1 + 0.1875)
? ? ? dingcun = fuli_small
? ? ? fuli_big = fuli_big + fuli_small
? ? ? DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_big) + Chr(13) + Chr(10)
? ? ? 'DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_small) + Chr(13) + Chr(10)
? Next
? 'fuli_big = fuli_small
? TextBox1.Text = DATAstring
? 結(jié)果_TextBox.Text = Str(fuli_big) + "元"
End Sub
代碼已測(cè)試。
一、測(cè)試需要的INI文件。名稱(chēng)為“setinfo.ini”,存放路徑為你解決方案里“Bin“文件夾的”Debug“文件夾里。
內(nèi)容:
[Location]
pnlTime.Location.X=787
pnlTime.Location.Y=0
[TopMost]
Top=True
二、操作INI文件的類(lèi)。新建一個(gè)類(lèi),類(lèi)中內(nèi)容為:
Public?Class?Class1
Public?Declare?Function?GetPrivateProfileString?Lib?"kernel32"?Alias?"GetPrivateProfileStringA"?_
(?_
ByVal?lpApplicationName?As?String,?_
ByVal?lpKeyName?As?String,?_
ByVal?lpDefault?As?String,?_
ByVal?lpReturnedString?As?String,?_
ByVal?nSize?As?Int32,?_
ByVal?lpFileName?As?String?_
)?As?Int32
End?Class
三、界面代碼:
Imports?System.IO?'for?path
Public?Class?Form1
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
getINI()
End?Sub
Private?Sub?getINI()
Dim?iniclass?As?New?Class1?'
Dim?myBf?As?String?'get?set_info?開(kāi)辟存儲(chǔ)的內(nèi)存
myBf?=?New?String(CChar(""),?256)
Dim?myFN?As?String?'配置文件的文件路徑
myFN?=?Path.Combine(My.Application.Info.DirectoryPath,?"setinfo.ini")
Dim?myAN?As?String?'Application_NAME,也是Section名稱(chēng)
myAN?=?Me.TextBox1.Text
Dim?myKN?As?String?'KEY_NAME,關(guān)鍵字名稱(chēng)
myKN?=?Me.TextBox2.Text
Class1.GetPrivateProfileString(myAN,?myKN,?"",?myBf,?myBf.Length,?myFN)?'調(diào)用讀取INI文件的操作
TextBox3.Text?=?Microsoft.VisualBasic.Left(myBf,?InStr(myBf,?Chr(0))?-?1)?'截取有用部分,有必要
End?Sub
End?Class
四、測(cè)試截圖如下
這篇文章介紹了VB.NET設(shè)置屏幕分辨率、顏色位數(shù)、刷新率
實(shí)例代碼,有需要的朋友可以參考一下
復(fù)制代碼
代碼如下:
Private
Declare
Function
GetDeviceCaps
Lib
"gdi32"
(ByVal
hdc
As
Long,
ByVal
nIndex
As
Long)
As
Long
Private
Declare
Function
ChangeDisplaySettings
Lib
"user32"
Alias
"ChangeDisplaySettingsA"
(lpDevMode
As
Any,
ByVal
dwflags
As
Long)
As
Long
Private
Const
CCDEVICENAME
As
Long
=
32
Private
Const
CCFORMNAME
As
Long
=
32
Private
Const
DM_BITSPERPEL
As
Long
=
H40000
Private
Const
DM_PELSWIDTH
As
Long
=
H80000
Private
Const
DM_PELSHEIGHT
As
Long
=
H100000
Private
Const
DM_DISPLAYFLAGS
As
Long
=
H200000
Private
Const
DM_DISPLAYFREQUENCY
=
H400000
Private
Const
CDS_FORCE
As
Long
=
H80000000
Private
Const
BITSPIXEL
As
Long
=
12
Private
Const
HORZRES
As
Long
=
8
Private
Const
VERTRES
As
Long
=
10
Private
Const
VREFRESH
=
116
Private
Type
DEVMODE
dmDeviceName
As
String
*
CCDEVICENAME
dmSpecVersion
As
Integer
dmDriverVersion
As
Integer
dmSize
As
Integer
dmDriverExtra
As
Integer
dmFields
As
Long
dmOrientation
As
Integer
dmPaperSize
As
Integer
dmPaperLength
As
Integer
dmPaperWidth
As
Integer
dmScale
As
Integer
dmCopies
As
Integer
dmDefaultSource
As
Integer
dmPrintQuality
As
Integer
dmColor
As
Integer
dmDuplex
As
Integer
dmYResolution
As
Integer
dmTTOption
As
Integer
dmCollate
As
Integer
dmFormName
As
String
*
CCFORMNAME
dmUnusedPadding
As
Integer
dmBitsPerPel
As
Integer
dmPelsWidth
As
Long
dmPelsHeight
As
Long
dmDisplayFlags
As
Long
dmDisplayFrequency
As
Long
End
Type
Private
Sub
cmdChangeDesktopMode_Click()
Dim
DM
As
DEVMODE
With
DM
.dmPelsWidth
=
CInt(txtNewWidth.Text)
.dmPelsHeight
=
CInt(txtNewHeight.Text)
.dmBitsPerPel
=
CInt(txtNewColor.Text)
.dmDisplayFrequency
=
CInt(txtNewFreq.Text)
.dmFields
=
DM_PELSWIDTH
Or
DM_PELSHEIGHT
Or
DM_BITSPERPEL
Or
DM_DISPLAYFREQUENCY
.dmSize
=
LenB(DM)
End
With
If
ChangeDisplaySettings(DM,
CDS_FORCE)
Then
MsgBox
"錯(cuò)誤!不支持此模式!"
End
If
End
Sub
Private
Sub
Form_Load()
txtOldWidth.Text
=
GetDeviceCaps(Me.hdc,
HORZRES)
txtOldHeight.Text
=
GetDeviceCaps(Me.hdc,
VERTRES)
txtOldColor.Text
=
GetDeviceCaps(Me.hdc,
BITSPIXEL)
txtOldFreq.Text
=
GetDeviceCaps(Me.hdc,
VREFRESH)
End
Sub