vb程序设计实例

时间:2024-09-07 03:57:07编辑:阿星

vb程序设计

VB是VisualBasic编程语言编写计算机程序需要使用计算机编程语言。计算机编程语言是人和计算机“对话”的桥梁。就像人类的语言一样,计算机编程语言也有很多。目前较为广泛使用的语言有“C”、“Pascal”、“Basic”等。在众多的计算机编程语言中,以BASIC语言最为易学易用。BASIC是英文Beginner’sAllpurposeSymbolicInstructionCode的缩写,意思为初学者通用符号指令代码,一直都是程序设计入门的首选语言。1991年,VisualBasic(简称VB)面世,他是第三代BASIC语言,它不但秉承了BASIC语言的易学易用的优点,而且增加了图形界面设计工具。它简化了复杂的窗口程序编写过程,让编程者将更多的精力致力于问题的求解过程。

求一个简单的Visual Basic程序~~

Dim point_currentX, point_currentY '当前坐标
Dim point_recentX, point_recentY '前一点坐标
Dim isfirstpoint As Boolean '判断是否为第一点

Private Sub Form_Load()

isfirstpoint = True

End Sub

'获取当前鼠标点击的X,Y的坐标
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

point_currentX = X
point_currentY = Y
PSet (X, Y)

End Sub



Private Sub Command1_Click()
If isfirstpoint = True Then '把(0,0)改为你自己要求的第一点坐标即可
Picture1.Line (0, 0)-(point_currentX, point_currentY)
point_recentX = point_currentX
point_recentY = point_currentY
isfirstpoint = False
Else '用直线连接前一点与当前点
Picture1.Line (point_recentX, point_recentY)-(point_currentX, point_currentY)
point_recentX = point_currentX
point_recentY = point_currentY
End If
End Sub


vb程序设计是什么

  以VB程序设计语言为工具,对特定的问题进行分析,并设计出解题的算法,根据得到的算法,用VB语言编写出源程序的过程就是vb程序设计。

  VB是微软公司开发的一种通用的基于对象的程序设计语言,为结构化的、模块化的、面向对象的、包含协助开发环境的事件驱动为机制的可视化程序设计语言。是一种可用于微软自家产品开发的语言。


用VB设计霓虹灯广告牌制作程序

  才10分
  你要的是大屏幕字符或者ppt播放程序吧。
  给你点代码仅供参考;

  Public Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
  End Type
  Public Type ROWRECT
  oRT As RECT
  sa As String
  bMove As Boolean
  sOld As String
  End Type
  Public Declare Function FindWindow Lib "user32" _
  Alias "FindWindowA" (ByVal lpClassName As String, _
  ByVal lpWindowName As Long) As Long
  ' To set fram control as the parent of the slide show window
  Public Declare Function SetParent Lib "user32" _
  (ByVal hWndChild As Long, _
  ByVal hWndNewParent As Long) As Long

  Public Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
  Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
  ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
  ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  Public Const HWND_TOPMOST = -1&
  Public Const HWND_NOTOPMOST = -2&
  Public Const SWP_NOSIZE = &H1&
  Public Const SWP_NOMOVE = &H2&
  Public Const SWP_NOACTIVATE = &H10&
  Public Const SWP_SHOWWINDOW = &H40&


  Public Const DT_BOTTOM = &H8
  Public Const DT_CALCRECT = &H400
  Public Const DT_CENTER = &H1
  Public Const DT_CHARSTREAM = 4 ' Character-stream, PLP
  Public Const DT_DISPFILE = 6 ' Display-file
  Public Const DT_EXPANDTABS = &H40
  Public Const DT_EXTERNALLEADING = &H200
  Public Const DT_INTERNAL = &H1000
  Public Const DT_LEFT = &H0
  Public Const DT_METAFILE = 5 ' Metafile, VDM
  Public Const DT_NOCLIP = &H100
  Public Const DT_NOPREFIX = &H800
  Public Const DT_PLOTTER = 0 ' Vector plotter
  Public Const DT_RASCAMERA = 3 ' Raster camera
  Public Const DT_RASDISPLAY = 1 ' Raster display
  Public Const DT_RASPRINTER = 2 ' Raster printer
  Public Const DT_RIGHT = &H2
  Public Const DT_SINGLELINE = &H20
  Public Const DT_TABSTOP = &H80
  Public Const DT_TOP = &H0
  Public Const DT_VCENTER = &H4
  Public Const DT_WORDBREAK = &H10
  下面是timer控件里的代码。定时刷新产生动的效果。
  If mBchange And miChange > miShowWorkInfoTime + 1 Then

  ' moPptApp.Presentations.Count
  'If op.SlideShowSettings.Run.View.Slide.SlideNumber = 2 Then
  If moPptApp.Presentations.Count = 0 Then
  PicA.Visible = False
  miChange = 1

  'moPptPresentation.Close
  moPptApp.Quit
  DoEvents
  End If
  Else
  'PicA.Visible = False
  'If miChange = miShowWorkInfoTime + miShowWelcomeInfoTime Then miChange = 1 Else miChange = miChange + 1
  miChange = miChange + 1
  If miChange > 10000000 Then miChange = 0
  ' If miChange Mod 2 = 0 Then
  PicA.Cls ‘屏的左半部清空
  picB.Cls ‘屏的右半部清空

  If miChange Mod 100 = 0 Then s_loadData
  For iA = 0 To miRows - 1
  If moRectA(iA).sa "" Then


  If moRectA(iA).bMove Then moRectA(iA).oRT.Left = moRectA(iA).oRT.Left - 2

  If moRectA(iA).oRT.Left < 80 - miColWidth Then
  moRectA(iA).oRT.Left = miColWidth - 80
  End If
  moRectA(iA).oRT.Right = moRectA(iA).oRT.Left + miColWidth
  DrawText PicA.hdc, moRectA(iA).sa, -1, moRectA(iA).oRT, DT_CENTER Or DT_WORDBREAK ’这个是关键,在屏幕上重新写出字符。
  End If
  If moRectB(iA).sa "" Then

  If moRectB(iA).bMove Then moRectB(iA).oRT.Left = moRectB(iA).oRT.Left - 2

  If moRectB(iA).oRT.Left < 80 - miColWidth Then
  moRectB(iA).oRT.Left = miColWidth - 80
  End If
  moRectB(iA).oRT.Right = moRectB(iA).oRT.Left + miColWidth
  DrawText picB.hdc, moRectB(iA).sa, -1, moRectB(iA).oRT, DT_CENTER Or DT_WORDBREAK ’这个是关键,在屏幕上重新写出字符。

  End If

  s_MakeLine
  Next
  DoEvents
  ' End If

  End If
  DoEvents


上一篇:德芙巧克力广告曲

下一篇:谜踪之国2